Repository navigation
fix(pip): stop doubling the tool name in pip messages - #4053
Conversation
📊 Automated PR Analysis
SummaryFixes a cosmetic bug in Review Checklist
Linked issues: #4050 Analyzed automatically by wshm · This is an automated analysis, not a human review. |
b987a08 to
47f8fdf
Compare
`format!("Failed to run {} pip list", base_cmd)` was written for the
`uv pip` branch, so on the plain-pip path it printed "pip pip list".
Add `prog_label()` returning "uv pip" or "pip" and use it in all six
verbose/error strings. The executed argv was already correct.
Fixes rtk-ai#4050
3e2e4bb to
7520531
Compare
Protocol-zero-0
left a comment
There was a problem hiding this comment.
Checked this locally. base_cmd can only be "pip" or "uv" (line 28), so prog_label covers every case, and no "{} pip" strings are left in the file. On the uv fallback the verbose line is now right:
pip not found — falling back to `uv pip`
Running: uv pip list --format=json
The same label problem, in reverse, is still in the timer.track call a few lines up (run, ~line 50):
timer.track(
&format!("{} {}", base_cmd, args.join(" ")),
&format!("rtk {} {}", base_cmd, args.join(" ")),
...On the plain path that records pip list / rtk pip list, which is fine. On the uv path it records a command that never ran. With a stub uv on PATH and no pip, rtk pip list leaves this row in the tracking DB:
('uv list', 'rtk uv list')
What actually ran was uv pip list, and what the user typed was rtk pip list, so rtk gain --history shows a uv list entry that doesn't correspond to either. Using the helper there too would line it up:
&format!("{} {}", prog_label(base_cmd), args.join(" ")), // "uv pip list"
&format!("rtk pip {}", args.join(" ")), // what the user ranUp to you whether that belongs in this PR or a follow-up, since it's the same "wrong tool name in a label" class.
Overlap: your #4055 also edits src/cmds/python/pip_cmd.rs, and a trial merge of the two branches conflicts, so one will need a rebase after the other lands.
The uv-fallback path recorded 'uv list' / 'rtk uv list' in the tracking DB — a command that never ran and an invocation the user never typed. Same doubled/wrong-label bug class as rtk-ai#4050, spotted in PR rtk-ai#4053 review by reaching for base_cmd directly instead of prog_label(). Co-Authored-By: Claude Sonnet 5 <[email protected]>
|
@Protocol-zero-0 Thanks for reviewing it. I admit, it took me a moment to follow this explanation 😅 I get it now. Good catch. We can use I'm aware of the merge conflict. If you check my comment on #4055 I mentioned it. Once this PR is merged, I will rebase #4055 Thanks! |
KuSh
left a comment
There was a problem hiding this comment.
Round 2 of 3 — APPROVED, follow-ups filed
Claim: rtk pip … messages and tracking labels name the program that actually ran (pip … or uv pip …) instead of pip pip … / uv list.
Scope: accept (round 1 was a COMMENTED review with no blocking set; the tracking-label extension it asked for is in 05320b98).
Ran: pip 26.1.2 on a 389-package env × 16 rows (list, list --path <empty>, outdated --path <empty>, show pip, show <missing>, --version, no args; a pip on PATH that cannot start × list/outdated/install/quiet; uv-only PATH × list/outdated/show, with a stub uv that logs argv; no pip and no uv) × merge-base 5e0f92cd / head 05320b98; real uv 0.12.19 with pip absent (Docker, LC_ALL=C) × list/show on both binaries; rtk rewrite on 9 pip/uv spellings. Invariants: non-default targets (--path, extra args), under the hook (every row run as rtk pip …, the form the hook returns), split streams (stdout/stderr/exit captured per row), every decision (pip present / pip broken / uv only / neither). Exit codes match raw pip on all 16 rows. Savings 62% on pip list bytes (13532 → 5110; 71% by tracked tokens) vs the 20% floor (CONTRIBUTING.md). Gate: fmt, clippy, cargo test --all green on the head and on the head merged onto develop @45b0b4c3; mutating prog_label to "pip pip"/"uv" fails test_prog_label_never_doubles_pip.
Matrix: executed this round.
CI @05320b98: all green (run 36004437503, 10/10 jobs)
Blocks merge (0)
None.
Optional — will not hold merge
- The
Running:line onlist/outdatedstill omits the user's extra args (rtk -v pip list --userprintsRunning: pip list --format=json), andrtk pipwith no args printsRunning: pipwith a trailing space. Both are unchanged fromdevelop, cosmetic, and not what #4050 reports; leaving them.
Filed as follow-ups
- #4315
uv pip <sub>is rewritten tortk pip <sub>, which runs plainpipwheneverpipis on PATH — pre-existing (src/discover/rules.rsrewrite_prefixes+ the routing inrun()), outside this PR's hunks; filed as one row of #4315 (prefix-stripped rewrites: path, runner and alias prefixes; absorbs #1053, #3846, #3413 and others). - #4316
categorize_commandhas nouvarm, sortk uv …rows land inotherin the ecosystem mix — pre-existing insrc/core/tracking.rs, outside this PR's hunks; filed.
Checked and correct — no need to re-verify
- The label matches argv on every path: with a stub
uvlogging its argv,rtk -v pip listprintsRunning: uv pip list --format=jsonand the stub receivedpip list --format=json; with a brokenpip,rtk pip listfails withFailed to run pip list: …(waspip pip list), exit 1 on both binaries. - Tracking rows on the uv path are now
uv pip list/rtk pip list(wereuv list/rtk uv list, a command that never ran); the pip-path rows are byte-identical before and after.rtk gain --historyshowsrtk pip listfor both paths. - No sibling builds the same label:
grep '{} pip\|pip {}\|"uv pip'acrosssrc/hits only this file and theuv piprewrite prefix. - Real uv with
pipabsent gives identical stdout/stderr/exit on the two binaries forlistandshow. - The trial merge with #4055 still conflicts in this file; as agreed, #4055 rebases after this lands.
Your questions
- "Up to you whether that belongs in this PR or a follow-up" (round 1, on the
timer.tracklabels) → folded in by the author in05320b98; verified above.
Next
Nothing — approving.
Rounds: 2/3. Threads: 0 open, 0 resolved this round (round 1 posted no line threads).
Summary
rtk pip ...error and verbose messages printedpip pip listbecause the format strings were written for theuv pipbranch and reused on the plain-pip path.prog_label()helper ("uv pip" or "pip") and uses it in all six affected strings insrc/cmds/python/pip_cmd.rs. The executed argument was correct; only the message was wrong. This is just a costmetic fix.Test plan
cargo fmt --all && cargo clippy --all-targets && cargo test
test_prog_label_never_doubles_pipManual testing:
rtk -v pip list/pip outdated/pip installnow printRunning: pip list --format=jsonandFailed to run pip list: ...(waspip pip list).Running: uv pip list --format=json.