Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rye init script in a folder named python breaks rye causing symbolic loop #1235

Closed
0x00cl opened this issue Jul 16, 2024 · 2 comments
Closed

Comments

@0x00cl
Copy link

0x00cl commented Jul 16, 2024

Steps to Reproduce

  1. Install rye with the default values curl -sSf https://rye.astral.sh/get | bash
Welcome to Rye!

This installer will install rye to /home/tomas/.rye

This path can be changed by exporting the RYE_HOME environment variable.

Details:
  Rye Version: 0.36.0
  Platform: linux (x86_64)

✔ Continue? · yes
✔ Select the preferred package installer · uv (fast, recommended)
✔ What should running `python` or `python3` do when you are not inside a Rye managed project? · Run a Python installed and managed by Rye
✔ Which version of Python should be used as default toolchain? · [email protected]
Installed binary to /home/tomas/.rye/shims/rye
Bootstrapping rye internals
Fetching requested internal toolchain '[email protected]'
Downloading [email protected]
Checking checksum
Unpacking
Downloaded [email protected]
Updated self-python installation at /home/tomas/.rye/self

The rye directory /home/tomas/.rye/shims was not detected on PATH.
It is highly recommended that you add it.
✔ Should the installer add Rye to PATH via .profile? · yes
Added to PATH.
  1. Create a folder for a project mkdir -p myproject/python && cd myproject/python
  2. rye init --script
  3. rye sync
  4. Run rye add -d ruff or any other package. Or any other command where rye uses python.

Expected Result

Some sort of error or at least warning when running rye init --script inside a folder named python.

At first it wasn't obvious to me that Rye would end up using my package named python to execute commands internally and simply break without any error or warning, specially because at no point I executed explicitly any command to install my python in my system nor told rye to use that version.

This isn't a problem when simply running rye init inside a folder named python.

If you are wondering why I'm running rye init --script inside a folder named python, that is because I was creating a repository with a problem solved in different programming languages and one of them was python.

Maybe add an error when trying to execute inside a folder named python and a flag like -i or --ignore to ignore errors in case someone really knows what they are doing and wants to install their python anyway.

Actual Result

[~/myproject/python] $ rye add -d ruff
error: Failed to run uv compile DEBUG uv 0.2.22
DEBUG Starting Python discovery for Python 3.12.3
DEBUG Looking for exact match for request Python 3.12.3
DEBUG Searching for Python 3.12.3 in system path
DEBUG Failed to query Python interpreter at `/home/tomas/myproject/python/.venv/bin/python3`
error: Failed to query Python interpreter at `/home/tomas/myproject/python/.venv/bin/python3`
  Caused by: Too many levels of symbolic links (os error 40)
. uv exited with status: exit status: 2

Even on other projects it will stop working unless I reinstall rye

[~/myproject] $ mkdir -p foobar && cd foobar
[~/myproject/foobar] $ rye init
success: Initialized project in /home/tomas/myproject/foobar/.
  Run `rye sync` to get started
[~/myproject/foobar]$ rye sync
Initializing new virtualenv in /home/tomas/myproject/foobar/.venv
Python version: [email protected]
DEBUG uv 0.2.22
DEBUG Checking for Python interpreter at path `/home/tomas/.rye/py/[email protected]/bin/python3`
  × Failed to query Python interpreter at `/home/tomas/.rye/py/[email protected]/bin/python3`
  ╰─▶ Too many levels of symbolic links (os error 40)
error: failed creating virtualenv ahead of sync

Caused by:
    0: failed to initialize virtualenv
    1: Failed to create self venv using /home/tomas/.rye/py/[email protected]/bin/python3. uv exited with status: exit status: 1

Version Info

rye 0.36.0
commit: 0.36.0 (12c024c7c 2024-07-07)
platform: linux (x86_64)
self-python: [email protected]
symlink support: true
uv enabled: true

Stacktrace

No response

@bluss
Copy link
Contributor

bluss commented Jul 16, 2024

It reproduces.

Project python and rye's self-python need to be the same version (I think).

The rye sync command wants to install the script python. It follows the existing symlink which goes to Rye's python install, and overwrites the file ~/.rye/py/[email protected]/bin/python3.12 (!) with a python script snippet.

I think the overwriting qualifies as a bug in uv? @charliermarsh @zanieb

@zanieb
Copy link
Member

zanieb commented Jul 18, 2024

Should be fixed by astral-sh/uv#5165 in the next uv release. Thank you!

@zanieb zanieb closed this as completed Jul 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants