Skip to content

fix(tool-stub): keep env_with_path instead of rebuilding PATH - #12322

Merged
jdx merged 1 commit into
jdx:mainfrom
tmkx:fix/tool-stub-preserve-caller-path
Aug 23, 2026
Merged

jdx merged 1 commit into
jdx:mainfrom
tmkx:fix/tool-stub-preserve-caller-path

Conversation

@tmkx

@tmkx tmkx commented Aug 23, 2026 •

Copy link
Copy Markdown
Contributor

Non-cached tool-stub exec rebuilt PATH from pristine env, which dropped project _.path dirs from __MISE_DIFF and broke nested LookPath of sibling stubs. Rebuilding from the caller PATH could also let an outer task's install dirs shadow the stub-selected version.

Keep toolset.env_with_path (already includes _.path and filters outer install dirs) and only prepend backend dependency bins (#7777).

Summary by CodeRabbit

Summary by CodeRabbit

  • Bug Fixes
    • Fixed tool execution so caller-provided PATH entries are preserved, including paths configured through environment settings.
    • Improved nested and sibling tool discovery when using non-cached tool stubs.
    • Ensured the tool version selected by a stub takes precedence over versions provided by an outer task.
  • Tests
    • Added end-to-end coverage verifying sibling commands remain discoverable and the selected tool version is used during tool-stub execution.

@coderabbitai

coderabbitai Bot commented Aug 23, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Central YAML (inherited), Organization UI (inherited)

Review profile: CHILL

Plan: Pro Plus

Run ID: f92d9a8c-9998-470d-8c78-1cfdfec8b8b0

📥 Commits

Reviewing files that changed from the base of the PR and between bc0ba12 and a8a3007.

📒 Files selected for processing (1)
  • src/cli/tool_stub.rs

Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.


📝 Walkthrough

Walkthrough

Tool-stub execution now uses env_with_path as the PATH base and prepends backend dependency paths when present. End-to-end tests cover sibling lookup and stub-selected version precedence during non-cached execution.

Changes

Tool-stub PATH preservation

Layer / File(s) Summary
Preserve PATH and validate tool resolution
src/cli/tool_stub.rs, e2e/cli/test_tool_stub_preserves_caller_path_slow
Tool-stub execution preserves the PATH from env_with_path and prepends backend dependency paths. The tests verify sibling lookup and selection of the stub-provided version over an outer task version.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Merge Risk: ⚪ Minimal · up to a8a30

This change preserves project PATH entries while avoiding unintended outer task install directories and adding only backend dependency bins; no actionable merge-blocking risk remains beyond normal checks and review.

Suggested reviewers: jdx, risu729

Poem

A rabbit checks the PATH,
Stubs select the tool,
Sibling commands stay in reach,
Outer versions yield,
Cache-cleared runs confirm.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 1 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: preserving env_with_path instead of rebuilding PATH during tool-stub execution.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@greptile-apps

greptile-apps Bot commented Aug 23, 2026 •

Copy link
Copy Markdown
Contributor

Greptile Summary

The PR preserves the toolset-generated environment during non-cached tool-stub execution while prepending required backend dependency bins.

  • Retains project-configured _.path entries and filters inherited mise installation paths.
  • Adds slow end-to-end coverage for sibling discovery and stub-selected version precedence.
  • Corrects the new test file mode to the repository’s non-executable convention.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains; the inherited-tool shadowing issue is addressed by retaining the filtered toolset environment, and the executable-mode issue is fixed.

Important Files Changed

Filename Overview
src/cli/tool_stub.rs Reuses env_with_path, then prepends backend dependency bins without restoring the inherited outer tool paths implicated by the prior finding.
e2e/cli/test_tool_stub_preserves_caller_path_slow Adds regression coverage for both PATH preservation and version precedence, with the test now committed as mode 100644.

Reviews (5): Last reviewed commit: "fix(tool-stub): keep env_with_path inste..." | Re-trigger Greptile

Comment thread src/cli/tool_stub.rs Outdated
Comment thread e2e/cli/test_tool_stub_preserves_caller_path_slow
@tmkx
tmkx force-pushed the fix/tool-stub-preserve-caller-path branch from 8834ed8 to bc0ba12 Compare August 23, 2026 08:33
@tmkx tmkx changed the title fix(tool-stub): preserve caller PATH on non-cached exec fix(tool-stub): keep env_with_path instead of rebuilding PATH Aug 23, 2026
@tmkx
tmkx force-pushed the fix/tool-stub-preserve-caller-path branch from bc0ba12 to 6df8738 Compare August 23, 2026 10:10
@tmkx

tmkx commented Aug 23, 2026

Copy link
Copy Markdown
Contributor Author

It 'suggests a command that works' {
$out = (& $script:miseExe exec usage -- usage --version 2>&1 | Out-String)
$out | Should -Match "usage-cli"
}

the output of usage --version is changed in recent releases.

@tmkx
tmkx force-pushed the fix/tool-stub-preserve-caller-path branch from 6df8738 to a8a3007 Compare August 23, 2026 11:55
Non-cached tool-stub exec rebuilt PATH from pristine env, which
dropped project _.path dirs from __MISE_DIFF and broke nested
LookPath of sibling stubs. Rebuilding from the caller PATH could
also let an outer task's install dirs shadow the stub-selected
version.

Keep toolset.env_with_path (already includes _.path and filters
outer install dirs) and only prepend backend dependency bins
(#7777).
@tmkx
tmkx force-pushed the fix/tool-stub-preserve-caller-path branch from a8a3007 to f46e2a8 Compare August 23, 2026 13:38
@jdx
jdx merged commit 2c5a1a6 into jdx:main Aug 23, 2026
29 checks passed
@tmkx
tmkx deleted the fix/tool-stub-preserve-caller-path branch August 24, 2026 01:11
jdx pushed a commit that referenced this pull request Aug 24, 2026
### 🚀 Features

- **(bootstrap)** add package plugin uninstall support by @jdx in
[#12332](#12332)

### 🐛 Bug Fixes

- **(brew-cask)** recognize Homebrew-owned casks by @donbeave in
[#12346](#12346)
- **(cli)** report a cd target it cannot enter instead of panicking by
@JamBalaya56562 in [#12314](#12314)
- **(config)** skip disabled idiomatic tracked configs by @xqm32 in
[#12194](#12194)
- **(config)** keep comments when saving from mise edit by @Marukome0743
in [#12319](#12319)
- **(config)** strip a byte-order mark before reading a version file by
@JamBalaya56562 in [#12325](#12325)
- **(doctor)** report installs that provide no executables by
@Marukome0743 in [#12321](#12321)
- **(env)** say why an age SSH identity could not be used by
@Marukome0743 in [#12339](#12339)
- **(env)** name the key and file behind an unexpanded $VAR by
@Marukome0743 in [#12316](#12316)
- **(go)** don't hand go install a GOROOT from another Go by
@Marukome0743 in [#12342](#12342)
- **(task)** treat a SIGINT-killed child as an interruption by
@Marukome0743 in [#12323](#12323)
- **(task)** preserve string type for usage value flags by @jdx in
[#12355](#12355)
- **(tasks)** tell Windows users why a task file was skipped by
@JamBalaya56562 in [#12324](#12324)
- **(tool-stub)** keep env_with_path instead of rebuilding PATH by @tmkx
in [#12322](#12322)
- **(watch)** restore the controlling terminal from a drop guard by
@Marukome0743 in [#12328](#12328)

### 🚜 Refactor

- **(cli)** keep one copy of the task-flag escape rule by
@JamBalaya56562 in [#12343](#12343)

### 📚 Documentation

- **(tasks)** point extensionless pwsh tasks at MISE_TASK_DIR by
@JamBalaya56562 in [#12313](#12313)

### 📦️ Dependency Updates

- update rust crate aube-registry to v2.1.0 by @renovate[bot] in
[#12348](#12348)
- bump aube to 2.1.0 by @jdx in
[#12351](#12351)
- bump usage to 6.2.0 by @jdx in
[#12354](#12354)

### 📦 Registry

- fix usage version test by @jdx in
[#12349](#12349)
- install oc from a channel directory by @Marukome0743 in
[#12326](#12326)

### Chore

- **(ci)** use github runners for fork prs by @jdx in
[#12345](#12345)
- **(ci)** prevent cache warmer starvation by @jdx in
[#12350](#12350)

### New Contributors

- @tmkx made their first contribution in
[#12322](#12322)
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.

2 participants