Skip to content

Stop mise wrappers recursing when mise's activation variables are missing - #13769

Open
andrew-boyd wants to merge 1 commit into
omacom:quattrofrom
andrew-boyd:fix-mise-wrapper-recursion
Open

andrew-boyd wants to merge 1 commit into
omacom:quattrofrom
andrew-boyd:fix-mise-wrapper-recursion

Conversation

@andrew-boyd

@andrew-boyd andrew-boyd commented Sep 29, 2026 •

Copy link
Copy Markdown

A wrapper from omarchy-mise-install ends in exec mise x <package> -- <bin>, and mise x looks <bin> up by name. It puts the directories it added ahead of the rest of PATH, and it knows which those are from the variables mise activate exports (__MISE_DIFF). A process that starts a wrapper with an activated PATH but a reduced environment (a service, a sandbox, or a launcher that passes only a safe set of variables) leaves those out. mise x then treats the package's directory as an ordinary entry behind ~/.local/bin, finds the wrapper again, and the wrapper runs itself until something kills it, holding a CPU core the whole time.

This is the same loop #3685's fix addressed for exec "$bin"; mise x still reaches it through this path.

Reproduction (on a machine with the gh wrapper installed):

PATH_ACTIVE=$(bash -lic 'printf %s "$PATH"')
env -i HOME="$HOME" PATH="$PATH_ACTIVE" timeout 8 ~/.local/bin/gh --version; echo "exit=$?"
# exit=124: the wrapper loops until the timeout

With this change the same command prints the gh version at once.

Change

  • The wrapper resolves the bin inside the package's install with mise which --tool <package> <bin> and hands mise x that path. It exits with mise's error if the bin cannot be resolved.
  • A migration regenerates wrappers on the current template, using the exact-match approach of the --quiet migration, so edited wrappers are left alone.
  • Tests cover the generated wrapper's calls, the new migration, and the updated expectations in the existing migration and agent tests.

Testing

  • mise-install, mise-wrapper-quiet-migration, mise-wrapper-which-migration, hermes-mise-migration, and default-agent tests pass on an Omarchy machine.
  • A full test/shell run before and after the change shows the same set of failures, with no new ones.
  • The reproduction above loops with the old wrapper and completes with the new one for gh.

…sing

A wrapper ends in `exec mise x <package> -- <bin>`, and `mise x` looks <bin>
up by name. It puts the directories it added ahead of the rest of PATH, and
it knows which those are from the variables `mise activate` exports. A
wrapper started with an activated PATH but without those variables, as a
service, a sandbox, or any launcher that passes PATH through a reduced
environment does, sees the package's directory as an ordinary entry behind
~/.local/bin. `mise x` then finds the wrapper again, and the wrapper runs
itself until something kills it, holding a CPU core the whole time.

Resolve the bin inside the package's install with `mise which --tool` and
hand `mise x` that path. A migration regenerates the wrappers on disk.
@andrew-boyd
andrew-boyd force-pushed the fix-mise-wrapper-recursion branch from 90474af to 1cb0f23 Compare September 29, 2026 17:42
@sanjyay

sanjyay commented Sep 30, 2026

Copy link
Copy Markdown
Contributor

This is an independent community review and unaffiliated with the Omarchy team, intended to help prepare PRs for their review.

Tested commit 1cb0f23f1ff1a230caf26acaeffac6d19d969873 in a clean Omarchy test environment.

Verification Summary

  • Base Reproduction (origin/quattro): On the base branch, wrappers generated by omarchy-mise-install invoked exec mise x $package_arg -- $bin_arg "$@". When launched in a stripped or service environment (where PATH contains ~/.local/bin but mise activation state variables like __MISE_DIFF are missing), mise x performed a PATH lookup for the bare command name and re-invoked ~/.local/bin/<command>, causing an infinite recursion loop that pegged CPU usage. Running the updated test on base reproduced the failure:
    mise use -g --quiet npm:playwright
    mise x npm:playwright -- playwright
    not ok - the wrapper resolves its bin inside the package
    
  • PR Branch Verification (pr-13769):
    • Resolving the binary upfront via bin=$(mise which --tool $package_arg $bin_arg) || exit 1 provides mise x with the fully-qualified install path, preventing name lookup from recurring back into ~/.local/bin.
    • Migration migrations/1790702027.sh safely detects exact matches of the legacy template and re-runs omarchy-mise-install while preserving custom-edited wrappers and unrelated binaries. Idempotent re-runs cleanly no-op.
    • All 10 checks in mise-install-test.sh and mise-wrapper-which-migration-test.sh pass.
    • Sibling test suites (mise-wrapper-quiet-migration-test.sh, default-agent-test.sh) pass with updated mock call expectations.
    • omarchy commands --check passed across 467 commands.
Verification output
$ bash ./test/shell.d/mise-install-test.sh
ok - a normal install writes a wrapper that names its package
ok - the wrapper runs the bin from the package's install
ok - a package name with shell characters reaches mise as one argument
ok - command names that are not plain file names are refused
ok - an escaping command name removes nothing outside ~/.local/bin

$ bash ./test/shell.d/mise-wrapper-which-migration-test.sh
ok - migration moves a wrapper onto mise which
ok - migration preserves package and bin names
ok - migration is idempotent
ok - migration only rewrites wrappers it recognizes
ok - migration succeeds when ~/.local/bin is missing

$ omarchy commands --check
Command metadata check passed (467 commands)

The solution cleanly resolves the recursion hazard, and the migration safety checks (exact template matching and size guard) ensure existing customized wrappers are left untouched.

If you'd prefer not to receive these independent reviews on your PRs, reply to this comment and say so, and I won't review your future PRs.

@omarchybot

Copy link
Copy Markdown
Collaborator

Reviewed by Claude Opus 5.5, with Codex Medium as a second opinion. The bug is real: the same loop has been reproduced on a disposable Omarchy worker for #8692 and #9583. Several open pull requests fix it, and #8692 fixes it more tightly than this one. So I recommended #8692 to the maintainer, read this branch rather than running it, and did not run it on a worker.

Why #8692. This branch resolves the binary with mise which --tool <package> <bin>, and that lookup is not limited to the named package. On mise 2026.9.14, mise which --tool gh node returns node's binary, not an error. So if a package does not ship the binary its wrapper names, but another active tool does, this wrapper runs the other tool's binary, at bin/omarchy-mise-install line 65. #8692 looks only in mise bin-paths <package>. When the package has no such executable it exits with an error, and otherwise it hands mise x the same kind of absolute path this branch does. The test stub here always answers /installs/<bin>, so it cannot catch this case. #13090 uses the same mise which --tool lookup. #9583 falls back to the bare name, which loops. #13470 and #13614 turn the loop into an error rather than running the tool.

Second opinion. Codex Medium was given this pull request and its competitors without my conclusion, and also picked #8692. It traced the behaviour to mise's toolset builder, which adds the --tool argument to the configured toolset rather than filtering to it, and reproduced the same mise which --tool gh node result. It found no other defect in this branch. Its independence is not guaranteed. This branch also conflicts with quattro in test/shell.d/default-agent-test.sh.

Nothing is needed from you for now. This waits on the maintainer, who has the competing fixes to choose between.

@jdx

jdx commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

@omarchybot #9596 should be the correct fix here

@omarchybot

Copy link
Copy Markdown
Collaborator

Rechecked by Claude Opus 5.5, with Codex Medium as a second opinion, after @jdx pointed at #9596 and #8692's author marked it a draft in favour of #9596. The head of this branch has not moved, and the earlier finding still stands: on mise 2026.10.0, mise which --tool gh node still returns node's binary rather than an error, so the lookup at bin/omarchy-mise-install line 65 can run another active tool's binary when the package does not ship the one the wrapper names.

#9596. It replaces Omarchy's default wrappers with mise's native lazy shims, and its migration removes the known default wrappers. It does not change bin/omarchy-mise-install, which still writes exec mise x <package> -- <bin>, so a wrapper made with it afterwards, or one the migration does not recognise, can still loop. It is a different design from the fixes here, and whether Omarchy adopts it is the maintainer's decision, not the bot's.

The narrow fixes. Codex Medium was given this pull request and its competitors without my conclusion. It again picked #8692 as the tightest fix, with the caveat that its author has now withdrawn it in favour of #9596. It also judged #13614 a sound alternative, because it checks that the resolved path is inside the requested package's install. It agreed about the mise which --tool lookup here, tracing it to mise's toolset builder, and found nothing else wrong with this branch. Its independence is not guaranteed. This branch still conflicts with quattro in test/shell.d/default-agent-test.sh. It was read, not run on a worker, because it is not the recommended fix.

Nothing is needed from you for now. This waits on the maintainer, who has #9596 and the narrow fixes to choose between.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants