fix(discover): normalize venv/absolute paths with binary preservation (#1053)#1378
fix(discover): normalize venv/absolute paths with binary preservation (#1053)#1378Timber125 wants to merge 1 commit intortk-ai:developfrom
Conversation
📊 Automated PR Analysis
SummaryFixes a bug where commands invoked via absolute or virtualenv paths (e.g., Review Checklist
Analyzed automatically by wshm · This is an automated analysis, not a human review. |
9424b94 to
ac5e444
Compare
|
Problem: Normalizing Reworking to implement the three-part fix from #1053:
Will reopen when ready. |
d8f6af8 to
526230d
Compare
…rtk-ai#1053) The naive approach of stripping .venv/bin/ prefixes and emitting bare `rtk pytest` changes execution semantics: handlers resolve via PATH instead of the original venv binary. This implements the three-part fix: 1. Normalize path-prefixed commands for matching only 2. Emit RTK_BIN_PATH=<original_bin> env var in rewritten commands 3. Handlers (pytest, ruff, mypy, pip) honor the override via override_command() before falling back to PATH resolution Closes rtk-ai#1053 Refs rtk-ai#1206 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
526230d to
96e315a
Compare
Summary
Fixes the path-prefixed command rewrite issue described in #1053 and #1206.
The naive approach (strip
.venv/bin/prefix and emit barertk pytest) changes execution semantics: handlers callresolved_command("pytest")which resolves via PATH, not the original venv binary. When the venv isn't activated, this executes the wrong binary or fails.This PR implements the three-part fix from #1053:
strip_absolute_path()inrewrite_segment_inner()normalizes path-prefixed commands to find the matching registry rule, but doesn't discard the original pathRTK_BIN_PATH— when a path prefix is stripped, the rewritten command includesRTK_BIN_PATH=<original_bin>as an env var prefix (e.g.RTK_BIN_PATH=.venv/bin/python rtk pytest tests/)override_command()inutils.rschecksRTK_BIN_PATH; if the basename starts with "python", it uses-m <tool>module invocation, otherwise direct execution. All Python handlers (pytest, ruff, mypy, pip) use this before falling back to PATH resolution.Paths handled
.venv/bin/pytest tests/RTK_BIN_PATH=.venv/bin/pytest rtk pytest tests/.venv/bin/python -m pytest tests/RTK_BIN_PATH=.venv/bin/python rtk pytest tests//usr/bin/grep -rn pattern src/RTK_BIN_PATH=/usr/bin/grep rtk grep -rn pattern src/pytest tests/(no path)rtk pytest tests/(no RTK_BIN_PATH)Test plan
RTK_BIN_PATHRTK_BIN_PATHvaluescargo fmt --all && cargo clippy --all-targets && cargo test --allcleanCloses #1053
Refs #1206
🤖 Generated with Claude Code