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

find_uv_bin fails to find uv when already inside a virtualenv #10194

Open
ssbarnea opened this issue Dec 27, 2024 · 1 comment · May be fixed by #10195
Open

find_uv_bin fails to find uv when already inside a virtualenv #10194

ssbarnea opened this issue Dec 27, 2024 · 1 comment · May be fixed by #10195
Assignees
Labels
question Asking for clarification or support

Comments

@ssbarnea
Copy link

I am inside a virtualenv that was created using mise and uv where uv is installed

Code to reproduce:

echo $VIRTUAL_ENV
/Users/ssbarnea/.venv

❯ which python3
/Users/ssbarnea/.venv/bin/python3

❯ which uv
/Users/ssbarnea/.config/mise/installs/python/3.13.0/bin/uv

❯ python3 -c "from uv._find_uv import find_uv_bin; print(find_uv_bin())"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
    from uv._find_uv import find_uv_bin; print(find_uv_bin())
                                               ~~~~~~~~~~~^^
  File "/Users/ssbarnea/.config/mise/installs/python/3.13.0/lib/python3.13/site-packages/uv/_find_uv.py", line 37, in find_uv_bin
    raise FileNotFoundError(path)
FileNotFoundError: /Users/ssbarnea/.local/bin/uv

That is breaking tox-uv plugin which needs this functionality. I think that fixing this should be quite easy and I will try to propose a patch.

I should mention that in this case the venv was created with use system packages option, and probably this is why uv module is present but fails to find its own script (executable in our case), because that script is not inside the venv own script directory but it is inside system python script directory.

In fact if find_uv_bin implementation would have used shutil.which to find the executable it would have worked.

ssbarnea added a commit to ssbarnea/uv that referenced this issue Dec 27, 2024
@zanieb
Copy link
Member

zanieb commented Dec 28, 2024

In fact if find_uv_bin implementation would have used shutil.which to find the executable it would have worked.

It's very intentional that we do not use that as it would find an arbitrary uv installation rather than the one corresponding to the Python module.

@zanieb zanieb self-assigned this Jan 6, 2025
@zanieb zanieb added the question Asking for clarification or support label Jan 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Asking for clarification or support
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants