Skip to content

fix(shim): use snap payload for unix shims - #12035

Merged
jdx merged 2 commits into
mainfrom
agent/fix-snap-shim-target
Aug 15, 2026
Merged

jdx merged 2 commits into
mainfrom
agent/fix-snap-shim-target

Conversation

@jdx

@jdx jdx commented Aug 15, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • resolve Snap-installed mise shims to the payload beneath Snap's refresh-stable current symlink
  • share the target resolver with mise doctor so validation matches reshim
  • add unit and e2e coverage for the Snap revision layout

Root cause

/snap/bin/mise is a symlink to the snap dispatcher, which identifies the application from argv[0]. When a mise shim such as node points there, snapd sees node instead of mise and runs the snap CLI rather than mise's shim dispatcher.

The fix bypasses /snap/bin only when the running mise executable is beneath $SNAP. Other installations retain the PATH-visible executable so package-manager launchers remain stable across upgrades.

Refs #12027

Testing

  • cargo test --locked --bin mise shims::tests::snap_mise_bin
  • mise run test:e2e e2e/cli/test_reshim_with_shims_on_path
  • scoped hk run check --safe --format json for the three changed files

AI-assisted — Tool: Codex; model: unavailable/unavailable; version: unavailable.


Note

Medium Risk
Changes shim target resolution for Snap users and shared doctor validation logic; scope is narrow but affects how every generated shim is validated and created on Unix when SNAP is set.

Overview
Fixes Snap installs where tool shims pointed at the snapd dispatcher (e.g. /snap/bin/mise), so argv[0] was the shim name (node, etc.) and snapd ran the wrong app instead of mise.

When $SNAP is set and the running binary lives under that revision, reshim and mise doctor now resolve the shim target via mise_bin_for_shims() to the payload under the refresh-stable current symlink (e.g. /snap/mise/current/bin/mise). Non-Snap installs keep the previous behavior (which_no_shims / MISE_BIN).

Adds unit tests for snap_mise_bin and an e2e scenario that simulates Snap’s revision + current layout and checks doctor agrees with reshim.

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

Summary by CodeRabbit

  • Bug Fixes

    • Fixed shim generation for Snap installations so shims consistently point to the stable active version.
    • Improved executable detection during forced reshim operations.
    • Fixed mise doctor so it correctly recognizes valid shims in Snap environments.
  • Tests

    • Added regression coverage for Snap-based installations, including stable path handling and validation of generated shims.

Resolve Snap-installed mise shims to the refresh-stable payload instead of the argv0-sensitive /snap/bin dispatcher. Keep doctor aligned with reshim and cover the Snap path behavior.\n\nRefs #12027.
@coderabbitai

coderabbitai Bot commented Aug 15, 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: 674c0741-8036-4d4b-a09e-d1bf9457b43e

📥 Commits

Reviewing files that changed from the base of the PR and between 1291655 and c753f61.

📒 Files selected for processing (1)
  • src/shims.rs
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/shims.rs

📝 Walkthrough

Walkthrough

The change adds Snap-aware mise executable resolution. Reshim and doctor analysis now use the shared resolver, which maps revision-specific Snap paths to the stable current path. Unit and end-to-end tests cover this behavior.

Changes

Snap shim resolution

Layer / File(s) Summary
Snap-aware resolution integration
src/shims.rs, src/cli/doctor/mod.rs
mise_bin_for_shims() maps active Snap executables to the stable current path. reshim and analyze_shims use this resolver.
Resolution regression coverage
src/shims.rs, e2e/cli/test_reshim_with_shims_on_path
Tests cover Snap path conversion, unrelated path rejection, stable shim targets, and successful doctor analysis.

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

Merge Risk: ⚪ Minimal · up to c753f

The change localizes Snap shim target resolution and keeps existing behavior for other installations; no actionable merge-blocking risk remains beyond normal checks and review.

Sequence Diagram(s)

sequenceDiagram
  participant Reshim
  participant mise_bin_for_shims
  participant SnapMount
  participant Doctor
  Reshim->>mise_bin_for_shims: resolve mise executable
  mise_bin_for_shims->>SnapMount: inspect revision-specific path
  SnapMount-->>mise_bin_for_shims: return stable current path
  mise_bin_for_shims-->>Reshim: generate stable-targeted shims
  Doctor->>mise_bin_for_shims: resolve mise executable
  mise_bin_for_shims-->>Doctor: return stable current path
Loading

Possibly related PRs

  • jdx/mise#11641: Updates related shim executable resolution for legacy rtx binary recognition.

Poem

A rabbit checks the Snap path bright,
current keeps each shim in sight.
Reshim follows the stable trail,
Doctor finds no shims that fail.
Hop, hop, the paths align.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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 and concisely describes the main change: using the Snap payload for Unix shims.

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 15, 2026 •

Copy link
Copy Markdown
Contributor

Greptile Summary

The PR makes Unix shims created by Snap-installed mise target the refresh-stable payload beneath Snap’s current symlink and makes doctor use the same resolver.

  • Adds Snap-aware shim target resolution, including symlinked mount handling.
  • Aligns doctor’s expected shim target with reshim.
  • Adds unit and end-to-end coverage for Snap revision layouts.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains.

Important Files Changed

Filename Overview
src/shims.rs Adds the shared Snap-aware executable resolver and focused coverage for revision-specific and symlinked mount layouts.
src/cli/doctor/mod.rs Uses the shared shim target resolver so doctor compares against the same target reshim writes.
e2e/cli/test_reshim_with_shims_on_path Extends reshim coverage with a simulated Snap revision and refresh-stable current symlink.

Reviews (2): Last reviewed commit: "fix(shim): handle symlinked snap mount p..." | Re-trigger Greptile

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 1291655. Configure here.

Comment thread src/shims.rs Resolved
@github-actions

Copy link
Copy Markdown
Contributor

Instruction counts

Nothing was compared, and so nothing was gated. No series appears on both sides: either the base has no measurements recorded, or the two were measured on different runner classes, which are deliberately not comparable — counts shift between machine types by more than a real regression does.

New, nothing to compare against: env on bamboo-v2-ubuntu24.04-x64-30vcpu-24gb-rust1.97.1, hook-env on bamboo-v2-ubuntu24.04-x64-30vcpu-24gb-rust1.97.1, ls on bamboo-v2-ubuntu24.04-x64-30vcpu-24gb-rust1.97.1, registry on bamboo-v2-ubuntu24.04-x64-30vcpu-24gb-rust1.97.1, startup on bamboo-v2-ubuntu24.04-x64-30vcpu-24gb-rust1.97.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.

1291655edacf vs 35f5f1b7a0a7 · measured on the runner, not pushed to the history.

@jdx
jdx enabled auto-merge (squash) August 15, 2026 11:24
@jdx
jdx merged commit 1480f74 into main Aug 15, 2026
29 of 30 checks passed
@jdx
jdx deleted the agent/fix-snap-shim-target branch August 15, 2026 11:33
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