Skip to content

Fix recursive mise wrappers by executing resolved binaries - #14880

Open
DonnieFi wants to merge 2 commits into
omacom:quattrofrom
DonnieFi:fix/mise-wrapper-absolute-executable
Open

DonnieFi wants to merge 2 commits into
omacom:quattrofrom
DonnieFi:fix/mise-wrapper-absolute-executable

Conversation

@DonnieFi

Copy link
Copy Markdown

Summary

Fixes #7234.

Omarchy's generated mise wrappers can resolve their bare command name back to themselves when ~/.local/bin precedes mise's shims. On this machine a claude auth status probe remained alive for 18 minutes and consumed sustained CPU. Safe lookup reproduction and environment details: #7234 (comment)

  • Resolve the executable with mise which --tool after activation, and execute its absolute path through mise x to preserve the runtime environment.
  • Fail on unusable or self-resolving paths, including symlink and hardlink aliases.
  • Regenerate exact shipped wrappers with a migration while preserving custom scripts and symlinks.
  • Add bounded regression coverage for wrapper-first PATH, argument preservation, resolution failures, runtime environment, and migration idempotence.

Related prior proposals include #8692 and #14843. This is another implementation of the existing issue, with migration and focused regression coverage.

Validation

Passed: mise-install-test.sh, mise-wrapper-quiet-migration-test.sh, mise-wrapper-resolution-test.sh, mise-wrapper-resolution-migration-test.sh, ./test/cli, and git diff --check.

The default-agent test's updated wrapper assertions pass, but the suite subsequently fails on an existing Grok migration assertion: the migration uses mise unuse -y -g, while the assertion expects unuse -g. The same failure was reproduced on untouched upstream HEAD 77bfaca.

@greptile-apps

greptile-apps Bot commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

[High impact] The PR appears safe to merge, with the earlier real-mise coverage gap addressed.

Summary

The PR makes generated mise wrappers launch a resolved absolute executable through mise x, rather than risk finding themselves in PATH.

  • Mise wrappers launch the resolved executable instead of looking up its name again.
  • Existing mise wrappers are updated to use resolved executable paths.

No new actionable issues were found.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Run generated wrapper] --> B[Activate requested tool]
  B --> C[Resolve executable with mise which]
  C --> D{Usable absolute path and not this wrapper?}
  D -->|No| E[Exit with an error]
  D -->|Yes| F[Launch absolute path through mise x]
Loading

Reviews (2) · Last reviewed commit: "Test wrapper resolution offline against ..." · Reviewed by Greptile

Comment on lines +22 to +25
[[ $2 == "--tool" && $3 == "npm:example" && $4 == "tool" ]] || exit 91
printf '%s\n' "$OMARCHY_MISE_RESOLVED_BIN"
exit "${OMARCHY_MISE_WHICH_STATUS:-0}"
;;

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.

P2 Real mise remains untested

The fake mise which --tool returns a preset path, and the fake mise x supplies the runtime variables itself. This checks the wrapper's shell logic, but not whether real mise resolves the requested package and preserves its runtime when given an absolute executable path. These tests can pass even if that lookup or launch fails.

Add an offline test with real mise and a local tool fixture, keeping the wrapper first in PATH.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Added test/shell.d/mise-wrapper-real-test.sh, an offline integration test using real mise and a local asdf plugin plus a linked tool fixture. The test isolates HOME/config/data/cache/state, keeps the generated wrapper first in PATH, bounds each invocation with a timeout, and checks plugin-provided runtime variables plus empty/spaced/literal-glob arguments. It also verifies that real mise's legacy bare-name lookup returns the wrapper itself, reproducing the original failure condition without running a loop. Passed with mise 2026.10.5, alongside the existing resolution and migration regressions. The test skips explicitly if mise is unavailable.

@Sebo1411

Copy link
Copy Markdown
Contributor

Nice work @DonnieFi! This is definitely a cleaner and more robust approach than #14843. Fully in favor of merging this.

@jandrusk

Copy link
Copy Markdown

This looks good, and it's nicer than #14843. One question: have you tried the new mise which --tool $package_arg $bin_arg line with a real mise and a backend spec that carries options, like the muse http:muse[url=…,bin=muse,…] package? The real-mise test uses a plain local plugin, and the bracket specs are only exercised against the stub. It'd be good to know --tool accepts them.

@thebristolsound

Copy link
Copy Markdown

Note

Claude responding on behalf of Matt.

A data point for comparing this PR with the PATH-scrubbing variant suggested in #14831.

On my machine the wrapper directory enters PATH as /home/<user>/.local/share/../bin, not as ~/.local/bin. An installer's ~/.local/bin/env script prepends it in that spelling, and .bashrc, .zshrc and .profile all source that script. The scrub from #14831 only removes the literal $HOME/.local/bin entry, so the alias survives and the lookup still finds the wrapper:

P=":$PATH:"; P="${P//:$HOME\/.local\/bin:/:}"; P="${P#:}"; P="${P%:}"
PATH="$P" mise x copilot -- sh -c 'command -v copilot'
# /home/<user>/.local/share/../bin/copilot   <- still the wrapper

Resolving the binary with mise which and executing the absolute path, as this PR does, does not depend on how the directory is spelled in PATH. I patched my local wrappers to that shape on omarchy 4.0.4-1 and mise 2026.10.4:

exec mise x "copilot" -- "$(mise which "copilot" --tool "copilot")" "$@"

With the aliased directory first in PATH, gh, claude, codex, copilot and pi now return immediately. Before the patch, gh --version hung until a 60-second timeout.

@omarchybot

Copy link
Copy Markdown
Collaborator

I read this pull request at e8e5010: the diff, #7234, and the open pull requests that touch the same wrapper. I ran nothing on a worker, because the item stops before verification. Its classification is still open: I read it as a bug fix for #7234. The second opinion (Codex Medium) is reachable but did not classify it, because this machine's review budget for today was used up. Without a second classification it gets no label and no verification yet. It will be picked up again on a later pass.

It overlaps two open pull requests, so you can weigh them together. #8692 is older and fixes #7234 the same way: the wrapper resolves an absolute path before mise x runs it. It finds that path by searching mise bin-paths "$package" rather than calling mise which --tool. #9596 takes a different route: it replaces the generated wrappers with mise's native lazy shims, and is waiting on the maintainer as a feature. Which of the three should land is the maintainer's call, and this waits on them for it.

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.

mise wrappers still exec-loop when mise x falls back to a PATH lookup (residual case of #6349)

5 participants