Skip to content

fix(shim): attribute missing executables to configured tools - #11398

Merged
jdx merged 2 commits into
mainfrom
agent/shim-error-attribution
Jul 28, 2026
Merged

jdx merged 2 commits into
mainfrom
agent/shim-error-attribution

Conversation

@jdx

@jdx jdx commented Jul 28, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • associate failed shims with configured tools by tool identity
  • prefer a forced reinstall of the matching configured tool over suggestions from unrelated installed runtimes
  • use the same diagnostic for direct mise which calls

Root cause

When a shim could not resolve, mise scanned every installed tool version for any executable with the same filename. An inactive Node installation containing an npm-installed codex could therefore cause a failed configured Codex shim to recommend activating that Node version.

User impact

If a configured tool is installed but no longer exposes its namesake executable, mise now explains that its installation is incompatible with current backend metadata and recommends mise install --force <tool>@<version>. Unrelated tools that happen to contain the same executable are not presented as the primary remediation.

Validation

  • cargo test cli::args::backend_arg::tests::test_matches_bin_name_uses_tool_identity
  • cargo test unavailable_tool_message_prefers_matching_configured_tool
  • cargo fmt --all -- --check
  • regression test constructs configured Codex and Node versions and verifies only Codex appears in the repair command

Note

Low Risk
User-facing CLI/shim diagnostics only; no auth, install pipeline, or data-model changes beyond clearer error selection.

Overview
Fixes shim and mise which errors that blamed unrelated installed tools when another runtime happened to ship the same executable name (e.g. npm codex under Node vs configured Codex).

Adds BackendArg::matches_bin_name so resolution keys off tool identity (short / tool_name, with Windows .exe and case handling) instead of scanning every install for a matching filename.

When a configured tool is installed but does not expose the requested binary under current backend metadata, unavailable_configured_tool_message explains the mismatch and suggests mise install --force <tool>@<version>. That path runs from shim resolution and from mise which when lookup fails.

Reviewed by Cursor Bugbot for commit d31e4cf. Bugbot is set up for automated code reviews on this repo. Configure here.

Summary by CodeRabbit

  • Bug Fixes
    • Improved tool detection by matching backend tools more accurately across operating systems, including executable name normalization.
    • Improved error handling when a configured tool version doesn’t provide the requested executable, with clearer, more specific guidance.
    • Added an actionable “reinstall with mise install --force <tool>@<version>” message when appropriate.
    • Preserved existing guidance for tools that are not installed or not configured.

@coderabbitai

coderabbitai Bot commented Jul 28, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The change adds backend executable-name matching and uses configured tool metadata to produce targeted reinstall guidance when a requested shim executable is unavailable.

Changes

Configured tool shim diagnostics

Layer / File(s) Summary
Backend identity matching
src/cli/args/backend_arg.rs
Adds normalized binary-name matching for bare and backend-qualified tools, with platform-specific executable suffix handling and unit coverage.
Unavailable tool error flow
src/shims.rs, src/cli/which.rs
Detects configured tools whose installed versions lack the requested executable and reports a force-reinstall command before existing fallback errors; tests verify matching-tool selection.

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

Possibly related PRs

  • jdx/mise#11189: Extends related shim “not found” and no-version error handling.

Sequence Diagram(s)

sequenceDiagram
  participant WhichRun
  participant Toolset
  participant Shims
  WhichRun->>Toolset: look up requested executable
  WhichRun->>Shims: request unavailable configured tool message
  Shims->>Toolset: inspect configured versions and backend metadata
  Shims-->>WhichRun: return reinstall guidance or no message
  WhichRun-->>WhichRun: emit targeted error or existing fallback
Loading

Poem

A bunny found a missing bin,
And traced the tool it should have been.
“Force reinstall,” soft paws say,
The right tool wins the error way.
Hop, hop—clear shims today!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 60.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
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.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: shim errors now attribute missing executables to the configured tool.

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 Jul 28, 2026 •

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR improves attribution and remediation messaging when a configured tool no longer provides a requested executable.

  • Matches unavailable executables to configured tools by tool identity.
  • Recommends force-reinstalling matching configured versions.
  • Reuses the diagnostic for direct mise which calls.
  • Adds regression coverage for filtering unrelated installed runtimes.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains.

Important Files Changed

Filename Overview
src/cli/args/backend_arg.rs Adds platform-aware executable-name matching based on backend tool identity and focused unit coverage.
src/cli/which.rs Uses the configured-tool diagnostic when direct executable resolution fails.
src/shims.rs Adds targeted force-reinstall guidance and verifies unrelated configured tools are excluded.

Reviews (2): Last reviewed commit: "normalize Windows shim names" | Re-trigger Greptile

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
src/cli/args/backend_arg.rs (1)

755-765: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Cover the tool_name fallback in the unit test.

Both added codex cases end in codex for short and tool_name, so they do not exercise the second matching branch. Add an alias-shaped case such as dotnet-core matching dotnet (the existing test at Line 789 demonstrates that parsing shape).

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/cli/args/backend_arg.rs` around lines 755 - 765, Extend
test_matches_bin_name_uses_tool_identity with an alias-shaped BackendArg whose
short name differs from its tool_name, such as dotnet-core matching dotnet, and
assert that matches_bin_name returns true to cover the tool_name fallback
branch.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/cli/args/backend_arg.rs`:
- Around line 213-226: Update matches_bin_name to normalize executable-name
comparisons on Windows: remove the .exe suffix case-insensitively and compare
the resulting binary name against short and tool_name components
case-insensitively. Preserve the existing case-sensitive behavior on non-Windows
platforms.

---

Nitpick comments:
In `@src/cli/args/backend_arg.rs`:
- Around line 755-765: Extend test_matches_bin_name_uses_tool_identity with an
alias-shaped BackendArg whose short name differs from its tool_name, such as
dotnet-core matching dotnet, and assert that matches_bin_name returns true to
cover the tool_name fallback branch.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

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

Review profile: CHILL

Plan: Pro Plus

Run ID: 94ec6c21-c148-4af2-9a3d-1851994e59ef

📥 Commits

Reviewing files that changed from the base of the PR and between 8326b22 and 951b47c.

📒 Files selected for processing (3)
  • src/cli/args/backend_arg.rs
  • src/cli/which.rs
  • src/shims.rs

Comment thread src/cli/args/backend_arg.rs Resolved
@github-actions

github-actions Bot commented Jul 28, 2026 •

Copy link
Copy Markdown
Contributor

Instruction counts

benchmark trend instructions Δ wall (min) Δ
env ▁▁▁▃▂█▆▅▇▇ 84,286,066 → 84,288,376 +0.00% 21.35 → 18.84ms -11.78%
hook-env ▁▄▄▅▇█▇▅▆▇ 86,845,016 → 86,895,271 +0.06% 23.71 → 19.15ms -19.26%
ls ▁▆▆▆▇▇▆▇▇█ 76,321,308 → 76,365,820 +0.06% 17.68 → 15.54ms -12.11%
registry ▃▁▂▂▄▆▆▆▆█ 50,040,954 → 50,095,514 +0.11% 13.15 → 10.65ms -18.96%
startup ▅▁▁▂▂▅▅▅▅█ 15,672,973 → 15,725,064 +0.33% 8.93 → 7.81ms -12.58%

No instruction-count regression above 1%.

Only instruction counts gate. Wall clock is shown for context — on identical hardware it moves 4-20% run to run.

Measured by tak — instruction-counted CLI benchmarks, stored in this repository's git notes.

d31e4cfca220 vs 8326b22f0791 · measured on the runner, not pushed to the history.

@jdx jdx changed the title fix shim error attribution fix(shim): attribute missing executables to configured tools Jul 28, 2026
@jdx
jdx merged commit c3834f9 into main Jul 28, 2026
35 checks passed
@jdx
jdx deleted the agent/shim-error-attribution branch July 28, 2026 02:59
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.

1 participant