Repository navigation
fix(pip): fall back to uv when pip is on PATH but cannot start - #4055
obrienciaran wants to merge 4 commits into
Conversation
📊 Automated PR Analysis
SummaryFixes pip command routing so that when Review Checklist
Linked issues: #4054 Analyzed automatically by wshm · This is an automated analysis, not a human review. |
|
Both this and #4053 both touch |
`use_uv` only asked whether a `pip` file exists on PATH. A stale console script whose shebang names a deleted interpreter passes that check, so rtk exec'd it, got ENOENT, and never tried `uv` — even though the same machine works via `uv pip` once the dead script is removed. Keep the routing rule from rtk-ai#3389 (pip wins whenever it is present) but retry through `uv pip` when the spawn itself fails with NotFound and uv is available. Nothing ran on a spawn failure, so the retry is safe for `install` too. A one-line stderr notice says why the switch happened. Fixes rtk-ai#4054
124aec5 to
ce98db3
Compare
|
@KuSh Thanks for approving #4053! Maybe you could take a quick look at this related PR too? 🙏 Basically this PR introduces a new fallback. If pip is on the PATH but broken (for example it points at a Python that's been deleted), rtk now tries Note: rebased since #4053 was merged. |
|
Thanks for the detailed write-up in #4054 and for the tests here. I'd rather not take this one, because it extends a mechanism that should go away instead of fixing it. Measured against
The first row runs a program the caller did not name. For #4315 tracks fixing that once for every runner: pick the filter from the final tool and run the command as typed. I've added #4054's case there. With that in place |
use_uv only asked whether a
pipfile exists onPATHand doesn't check if it can actually run. Right now, a stale console script whose shebang names a deleted interpreter passes the check, so rtk exec'd it, gets ENOENT, and never triesuv; even though the same machine works viauv piponce the dead script is removed.Keep the routing rule from #3389 (
pipwins whenever it is present) but retry throughuv pipwhen the spawn itself fails withNotFoundanduvis available. Nothing ran on a spawn failure, so the retry is safe for install too. A one-line stderr notice says why the switch happened.Fixes #4054
Summary
rtk pip ...now retries viauv pipwhenpipis onPATHbut the OS can't start it (e.g. a stale shebang). Previously it failed with a bare "No such file or directory" and never trieduv.pipstill wins whenever present (pip install silently installed nothing on 0.40.0 (uv routed without a venv); regression test + docs still describe the old rule #3389). The fallback only kicks in after a failed spawn, so the normal path costs nothing new. When it does trigger, the cost is one failedexec(which was going to happen anyway), one extraPATHlookup foruv, and theuv piprun itself; plus one extrastderrline in the output.dispatch()helper, and addedis_spawn_not_found().docs/contributing/ARCHITECTURE.md.Test plan
cargo fmt --all && cargo clippy --all-targets && cargo test#[cfg(unix)]one that writes a real dead-shebang script to a tempdir, spawns it, and checks it's classified as not-found.pip+uv: printsrtk: pip is on PATH but could not be started — falling back to uv pip, thenpip listandpip installsucceed viauv (exit 0).pip+uv: unchanged, falls back the same as always.pip, nouv: same as alway, error kept, exit 1.pip+uv:pipruns,uvis never called