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

UV venv doesn't work on MacOS when Rye is installed #1791

Open
justinhauer opened this issue Feb 21, 2024 · 8 comments
Open

UV venv doesn't work on MacOS when Rye is installed #1791

justinhauer opened this issue Feb 21, 2024 · 8 comments
Labels
bug Something isn't working

Comments

@justinhauer
Copy link

Summary:
Out of the box, the tool doesn't work.

I have Rye installed in my system. When downloading UV to test this out, as it seems like Rye will soon be dead and I'll have to migrate to this tool. I get the following error:

uv platform: MacOS 14.4 (Intel x86)
uv version: uv 0.1.6

command:
uv venv test
× Querying Python at /Users/justin/.rye/shims/rye failed with status exit
│ status: 2:
│ --- stdout:
--- stderr:
│ error: unexpected argument found
│ ---

It appears that with both tools installed, UV is nerfed.

@zanieb zanieb added the bug Something isn't working label Feb 21, 2024
@zanieb
Copy link
Member

zanieb commented Feb 21, 2024

Thanks for the report! Rye won't be dead soon, we'll be helping maintain it.

Regarding the error, it seems weird that we're detecting rye as a Python executable. Can you provide output with the -v flag?

@methane
Copy link
Contributor

methane commented Feb 21, 2024

This is why this error happens.

let base_python = fs_err::canonicalize(python)?;
let interpreter = Interpreter::query(&base_python, platform, cache)?;

$ which python3
/Users/inada-n/.rye/shims/python3

$ python3 get_interpreter_info.py
{"markers": ...}

$ ~/.rye/shims/rye get_interpreter_info.py
error: unrecognized subcommand

Anyway, rye doesn't provide commands like python3.12 so we can not rye venv -p3.12 too.
More effort is needed to support rye managed python interpreters.

@MichaReiser
Copy link
Member

I haven't used rye myself but I wonder if this is the suggested workflow. I think the proposed way of using uv with rye is to use uv through rye. I think you can do that by setting rye config --set-bool behavior.use-uv=true. See https://lucumr.pocoo.org/2024/2/15/rye-grows-with-uv/

@MichaReiser MichaReiser added question Asking for clarification or support and removed bug Something isn't working labels Feb 21, 2024
@methane
Copy link
Contributor

methane commented Feb 21, 2024

rye doesn't have rye venv command. We can not create venv without project for now.

@mitsuhiko
Copy link
Collaborator

@zanieb i ran into that issue myself. The problem here is that the python and python3 shim by rye is detected by name. When uv canonicalizes, it tries with the rye name instead. For uv usage within rye that's not an issue because i always bypass the paths where this shows up, but it is an issue if you point it directly to one of the rye shims.

I see three options:

  1. pass a hidden env var as part of discovery that can force on the flag in uv
  2. always let rye hardlink the shims on all platforms to prevent the symlink resolving
  3. to not resolve symlinks in uv

@methane
Copy link
Contributor

methane commented Feb 21, 2024

Virtualenv can extend Python discovery and there are extensions for pyenv and rye.

Since it needs to be written in Python, difficut to support them from uv.

Another idea is creating directory like what scripts/bootstrap/install.py creates.
The directory containing python3 (default), python3.X, and python3.X.Y symlinks.
Shell script or Python script is enough for creating such directory for pyenv/rye.

uv already have UV_TEST_PYTHON_PATH for finding python from such directory.
By adding the directory to PATH temporary, tox and virtualenv can use it without extension.

@MichaReiser MichaReiser added bug Something isn't working and removed question Asking for clarification or support labels Feb 21, 2024
@MichaReiser
Copy link
Member

Possibly related to #1795

@methane
Copy link
Contributor

methane commented Feb 22, 2024

I find uv venv -p3.8 spam doesn't canonicalize symlink.

let formatted = PathBuf::from(format!("python{}.{}", versions[0], versions[1]));
let Some(executable) = Interpreter::find_executable(&formatted)? else {
return Ok(None);
};
let interpreter = Interpreter::query(&executable, platform, cache)?;

Why only find_default_python canonicalize python? Can we just stop canonicalize?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants