Skip to content

Unwrap uv run <tool> and uvx <tool> before registry lookup #1205

Open

Description

@ReinierKoops

Problem

When commands are wrapped with uv run or uvx, RTK fails to rewrite them even when it has a filter for the underlying tool.

Repros (rtk 0.35.0):

$ rtk rewrite "uv run pytest -q"
# exit 1 — no rewrite, even though rtk pytest exists

$ rtk rewrite "uvx ruff check ."
# exit 1 — no rewrite, even though rtk ruff exists

$ rtk rewrite "uv run python3 -c 'print(1)'"
# exit 1 — acceptable, python3 -c has no generic filter

$ rtk rewrite "uv sync"
# exit 3 → rtk uv sync  (uv sync is handled correctly)

Edge cases to consider:

  • uv run -- separator before tool name: uv run -- pytest
  • uv run --with <pkg> <tool>: uv run --with pytest-cov pytest
  • uvx --from <pkg> <tool>: uvx --from ruff ruff check .
  • Nested wrapping: uv run uv run pytest (probably just handle one level)

Expected behavior

uv run pytest -q → rtk pytest -q (strip the uv run wrapper, look up pytest in registry)
uvx ruff check . → rtk ruff check . (same for uvx)

If the unwrapped tool has no RTK filter, fall through to passthrough as today.

Impact

In this project alone: 3,523 uv run invocations and 99 uvx invocations per rtk discover -a — all currently passing through unfiltered.

Activity

  1. added
    effort-medium
    enhancement
    on Apr 10, 2026
  2. pszymkowiak commented on Apr 10, 2026

    @pszymkowiak
    Collaborator

    wshm · Automated triage by AI

    🔍 Automated Triage

    ✨ Category feature
    🟠 Priority high
    🎯 Confidence 91%

    Summary

    RTK should unwrap uv run <tool> and uvx <tool> prefixes before registry lookup, enabling existing filters to match the underlying tool; high impact given 3500+ currently unfiltered invocations.


    Triaged automatically by wshm · This is an automated analysis, not a human review.

  3. etaseoul-jason commented on Apr 13, 2026

    @etaseoul-jason

    Adding usage data: rtk discover reports 11 uvx commands in the last 30 days, all unhandled. Common pattern: uvx --with google-auth --with google-api-python-client script.py. Unwrapping before registry lookup would capture these.

  4. ahringer commented on Jul 16, 2026

    @ahringer

    v0.43.0 regressed this into silent test-loss (rewrites to uv run rtk pytest)

    Heads-up for anyone landing here: the v0.43.0 fixes (hook: rewrite pytest under uv run c8722bd, hook: treat uv run as a transparent prefix 34441dd) don't produce the expected rtk pytest — on a clean 0.43.0 install the hook now rewrites uv run pytest to uv run rtk pytest, which is worse than the pre-fix "no rewrite" behavior because it silently collects 0 tests instead of running them.

    Environment: rtk 0.43.0, Windows 11, global hook installed via rtk init -g.

    Repro:

    $ rtk rewrite "uv run pytest tests/"
    uv run rtk pytest tests/          # expected per this issue: rtk pytest tests/

    The consequence is a false green/false red, not an error:

    $ uv run rtk pytest --collect-only -q      # what the hook executes
    Pytest: No tests collected
    
    $ uv run pytest --collect-only -q          # raw, correct
    ...
    1398 tests collected

    uv run rtk pytest invokes rtk inside the uv environment, and pytest then runs outside uv's managed interpreter, so collection silently returns nothing. Because it exits cleanly, an agent reading the output concludes "no tests" rather than surfacing a failure.

    I also confirmed the documented knobs don't help on 0.43.0:

    • [hooks] transparent_prefixes = ["uv run"] — no effect (still uv run rtk pytest)
    • [hooks] exclude_commands = ["uv run"] / ["uv"] — no effect
    • [hooks] exclude_commands = ["pytest"] — stops the broken rewrite, but then output is unfiltered (no savings)
    • A trusted project-local .rtk/filters.toml with match_command = "^uv run pytest" does not override the built-in rewrite

    Working workaround (correct results and RTK's real pytest filter):

    rtk run "uv run pytest -q 2>&1" | rtk pipe -f pytest

    rtk run "..." is left untouched by the hook, so pytest runs correctly in uv's environment; rtk pipe -f pytest then applies the built-in pytest filter. Verified: a passing run collapses to Pytest: N passed, and failures keep full detail (test name, file:line, and the assertion message). This keeps uv run pytest intact rather than reconstructing it as rtk pytest, which sidesteps the environment-reconstruction problem entirely.

    Suggest reopening/relabeling since the intended uv run pytest → rtk pytest unwrap from this issue hasn't landed correctly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:clieffort-mediumenhancementhelp wantedpriority:high

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions