Distinguish uv tool install from uvx and emit correct install commands#183
Open
Distinguish uv tool install from uvx and emit correct install commands#183
Conversation
…mands Issue #133: a user on `uv tool install sqlit-tui` hits the missing-driver dialog, picks the "(Detected)" option, and gets `uvx --with PyMySQL sqlit-tui` — which fails with "An executable named `sqlit-tui` is not provided by package `sqlit-tui`." Even if the syntax were fixed to `uvx --from sqlit-tui --with PyMySQL sqlit`, that would only spawn an ephemeral sqlit; his persistent install is still driver-less. Root cause: `SystemProbe.is_uvx()` was matching `/uv/tools/`, which is the `uv tool install` path — not the uvx cache path. Every persistent install was misclassified as uvx, and the emitted uvx command was syntactically broken to boot (sqlit-tui is the package name, sqlit is the executable inside it). Fix: - `is_uvx()` now matches `/uv/environments-v2/` and `/uv/cache/archive-v0/`, where uvx actually stores ephemeral envs. - New `is_uv_tool_install()` matches `/uv/tools/` and gets its own `"uv-tool"` detection bucket, with command `uv tool install --reinstall --with X sqlit-tui` (the only way to add a dependency to a persistent uv tool install today — see astral-sh/uv#14746). - The uvx command is corrected to `uvx --from sqlit-tui --with X sqlit`. Closes #133.
ab83a9c to
aca23b4
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #133.
The bug:
SystemProbe.is_uvx()checks for/uv/tools/insys.executable, but that's actually theuv tool install(persistent) path.uvx(ephemeral) envs live under/uv/environments-v2/or/uv/cache/archive-v0/. So every `uv tool install` user gets misclassified as uvx and offered a uvx command — which is wrong on two counts:uvx --with PyMySQL sqlit-tuifails becausesqlit-tuiis the package name, but the executable inside it is calledsqlit. uv itself tells you: "Use `uvx --from sqlit-tui sqlit` instead."uvxspawns an ephemeral sqlit. The user's persistentuv tool installis still driver-less. To actually add a dependency to a persistent tool install today, you needuv tool install --reinstall --with X sqlit-tui(uv tool install --into add packages to an existing tool environment astral-sh/uv#14746 tracks a lighter-weight "inject" command).The fix:
is_uvx()now matches the real uvx paths (/uv/environments-v2/,/uv/cache/archive-v0/).is_uv_tool_install()owns the/uv/tools/check.detect_install_method()returns"uv-tool"or"uvx"distinctly.uv-tool:uv tool install --reinstall --with PyMySQL sqlit-tuiuvx:uvx --from sqlit-tui --with PyMySQL sqlitTests: 7 new tests in
tests/unit/test_install_strategy_uv.pypin: detection of each path, correct command shapes, and an explicit regression test that the old/uv/tools/→ uvx misclassification doesn't come back.