Skip to content

Distinguish uv tool install from uvx and emit correct install commands#183

Open
Maxteabag wants to merge 1 commit intomainfrom
uv-install-detection
Open

Distinguish uv tool install from uvx and emit correct install commands#183
Maxteabag wants to merge 1 commit intomainfrom
uv-install-detection

Conversation

@Maxteabag
Copy link
Copy Markdown
Owner

Fixes #133.

The bug: SystemProbe.is_uvx() checks for /uv/tools/ in sys.executable, but that's actually the uv 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:

  1. Syntax: the command uvx --with PyMySQL sqlit-tui fails because sqlit-tui is the package name, but the executable inside it is called sqlit. uv itself tells you: "Use `uvx --from sqlit-tui sqlit` instead."
  2. Semantic: even with correct syntax, uvx spawns an ephemeral sqlit. The user's persistent uv tool install is still driver-less. To actually add a dependency to a persistent tool install today, you need uv tool install --reinstall --with X sqlit-tui (uv tool install --in to 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/).
  • New is_uv_tool_install() owns the /uv/tools/ check.
  • detect_install_method() returns "uv-tool" or "uvx" distinctly.
  • The two install-option templates are different:
    • uv-tool: uv tool install --reinstall --with PyMySQL sqlit-tui
    • uvx: uvx --from sqlit-tui --with PyMySQL sqlit
  • Ordering updated so both appear near the detected method.

Tests: 7 new tests in tests/unit/test_install_strategy_uv.py pin: detection of each path, correct command shapes, and an explicit regression test that the old /uv/tools/ → uvx misclassification doesn't come back.

…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.
@Maxteabag Maxteabag force-pushed the uv-install-detection branch from ab83a9c to aca23b4 Compare April 19, 2026 09:51
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

Successfully merging this pull request may close these issues.

Can't install with psycopg2-binary

1 participant