Skip to content

Search in the user scheme scripts directory last in find_uv_bin#14191

Merged
zanieb merged 2 commits intomainfrom
zb/user-scheme-last
Aug 8, 2025
Merged

Search in the user scheme scripts directory last in find_uv_bin#14191
zanieb merged 2 commits intomainfrom
zb/user-scheme-last

Conversation

@zanieb
Copy link
Copy Markdown
Member

@zanieb zanieb commented Jun 21, 2025

We should definitely not pick up user-level installations unless we can't find uv anywhere else. Otherwise, e.g., we would find a uv installed with pipx install uv before the one matching the uv module.

@zanieb zanieb added the bug Something isn't working label Jun 21, 2025
@zanieb zanieb temporarily deployed to uv-test-registries June 21, 2025 18:43 — with GitHub Actions Inactive
@zanieb
Copy link
Copy Markdown
Member Author

zanieb commented Jun 21, 2025

Arguably breaking, but I'd be surprised if it had real-world implications. We can slot into v0.8 if we want though.

@Flamefire
Copy link
Copy Markdown

I suggest is searching the relative paths first: When uv is installed into <target>/../uv or <prefix>/lib/python/site-packages/uv you want <target>/bin or <prefix>/bin not /usr/bin, don't you? The latter might be something e.g. installed with apt-get and the former an update installed where the system-prefix isn't writable.

I can't see where it would find an unrelated "wrong" uv with the first logic. At worst it won't find anything, does it?

Maybe a more general "fix" is to have the uv binary import the uv module instead of the other way round like other Python "binaries" (actually executable scripts) do. If it really needs an executable binary (i.e. not a library) I guess that could be put next to/into the module in which case it is trivial to find.

Copy link
Copy Markdown

@ssbarnea ssbarnea left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@zanieb I tested this change with 4 combinations and it seems to be working well:

  • uv installed at system level for uv python and for mise python, had to use uv run python -m pip install --break-system-packages uv.whl and similar for mise.
  • venv created with uv env and with python -m venv
  • tested only on macOS

I did not test with pip --user level because that one is known that packages installed like this are not to be available to venvs regardless how they are created.

All these 4 combinations worked this way as python -m uv was able to return the correct uv. Obviously that the uv executable was not in path for most of them, but that was expected.

@zanieb
Copy link
Copy Markdown
Member Author

zanieb commented Jun 26, 2025

I suggest is searching the relative paths first: When uv is installed into /../uv or /lib/python/site-packages/uv you want /bin or /bin not /usr/bin, don't you?

Hm.. I think both the <target> and <prefix> cases are not common and I'm pretty hesitant to prioritize them above the other look up locations, even if there's only a small chance of false positives.

@Flamefire
Copy link
Copy Markdown

Hm.. I think both the <target> and <prefix> cases are not common and I'm pretty hesitant to prioritize them above the other look up locations, even if there's only a small chance of false positives.

In which case could there be a false positive? It looks at the location adjacent to the python module. That would work for pretty much all scenarios as this is the same location the binary would be for e.g. user or system installations, isn't it?

@zanieb
Copy link
Copy Markdown
Member Author

zanieb commented Jun 26, 2025

I mean, when we look 4 parents up we could just be looking in an arbitrary directory at that point?

@Flamefire
Copy link
Copy Markdown

I mean, when we look 4 parents up we could just be looking in an arbitrary directory at that point?

I see. Maybe we can match the parents against lib/python*/site-packages/uv to make this safe?

@zanieb
Copy link
Copy Markdown
Member Author

zanieb commented Jun 26, 2025

I considered that, but I was sort of hesitant to add more complexity. I can mull it over some more / seek feedback from more of the team.

@zanieb zanieb force-pushed the zb/find-prefix branch 2 times, most recently from 95088e3 to 8b369b4 Compare August 7, 2025 20:18
@zanieb zanieb force-pushed the zb/user-scheme-last branch from 1137c6c to 50a958d Compare August 7, 2025 21:16
@zanieb zanieb temporarily deployed to uv-test-registries August 7, 2025 21:18 — with GitHub Actions Inactive
@zanieb zanieb force-pushed the zb/user-scheme-last branch from 50a958d to 9eee403 Compare August 7, 2025 21:20
@zanieb zanieb temporarily deployed to uv-test-registries August 7, 2025 21:22 — with GitHub Actions Inactive
Base automatically changed from zb/find-prefix to main August 7, 2025 21:48
@zanieb zanieb force-pushed the zb/user-scheme-last branch from 9eee403 to 6bb9b73 Compare August 7, 2025 21:48
@zanieb zanieb marked this pull request as ready for review August 7, 2025 21:48
@zanieb zanieb temporarily deployed to uv-test-registries August 7, 2025 21:50 — with GitHub Actions Inactive
@zanieb zanieb temporarily deployed to uv-test-registries August 7, 2025 21:58 — with GitHub Actions Inactive
@zanieb zanieb force-pushed the zb/user-scheme-last branch from 4c6ae73 to bb1bb76 Compare August 8, 2025 11:33
@zanieb zanieb temporarily deployed to uv-test-registries August 8, 2025 11:36 — with GitHub Actions Inactive
@zanieb zanieb enabled auto-merge (squash) August 8, 2025 11:43
@zanieb zanieb merged commit a930290 into main Aug 8, 2025
95 checks passed
@zanieb zanieb deleted the zb/user-scheme-last branch August 8, 2025 11:46
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

Successfully merging this pull request may close these issues.

4 participants