Repository navigation
Exec mise wrappers by resolved path, not by name - #9583
mrdavidlaing wants to merge 4 commits into
Conversation
4480a14 moved the stubs from `exec "$bin"` to `exec mise x "$package" -- "$bin"` so the tool would resolve from mise's install dir rather than by name through PATH. It narrowed the loop but did not close it: mise still looks the bare name up in PATH, so it can find the stub again and exec itself forever, in the same PID, pinning a core. Four conditions have to line up, and they routinely do: ~/.local/bin precedes the tool's install dir, that install dir is already on PATH (so mise has nothing to prepend), the shims directory is on PATH, and the environment carries none of mise's session variables. That last one is why this hides — an interactive shell has them set and returns in ~50ms, while a systemd service, a git subprocess, or an agent runner does not. Seen in the wild as `gh auth git-credential get` spinning for 85 minutes and burning 35 minutes of CPU, with the git operation behind it hung the whole time, after git invoked the gh stub as its credential helper. Resolve the binary with `mise which` and exec that absolute path, so the name is never handed back for lookup. When resolution fails the stub falls back to the previous line, keeping today's behavior rather than breaking a tool mise cannot locate. Co-Authored-By: Claude Opus 5 <[email protected]>
getaaron
left a comment
There was a problem hiding this comment.
This seems reasonable - comments seem a little verbose (especially in tests)
quattro now writes the wrapper's package and bin through %q-quoted $package_arg and $bin_arg, so the resolved-path lines take the same quoting, mise which included. The new resolved-path assertion sits beside quattro's Cursor and Muse stub checks. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Reviewed and reproduced on a disposable Omarchy worker; the bug is real and this fixes it for newly written wrappers. Merged Reproduction (your recipe, Tests on the worker: Second opinion: Codex Medium reviewed the same head. It agreed that the loop is real, explaining it from mise's exec lookup: an install dir already on
It also pointed out that Waiting on the maintainer: whether this lands as is, or with a migration for the wrappers already installed. |
|
| else | ||
| exec mise x $package_arg -- $bin_arg "\$@" |
There was a problem hiding this comment.
Fallback restores the loop
If mise which returns no path, this branch passes the bare binary name to mise x again. When the wrapper precedes mise's install directory on PATH, that is the same invocation that can select the wrapper and run indefinitely. A failed resolution should not return to the self-recursing path.
| "$ROOT/bin/omarchy-mise-install" "$package" "$command" | ||
| OMARCHY_TEST_MISE_WHICH="/opt/resolved/$command" "$test_home/.local/bin/$command" --version | ||
| mapfile -t mise_calls <"$mise_history" | ||
|
|
||
| [[ ${mise_calls[2]} == "x $package -- /opt/resolved/$command --version" ]] || | ||
| fail "$command lazy stub execs the resolved path, not the bare name" |
There was a problem hiding this comment.
Test cannot catch self-execution
The new test supplies a fixed resolved path and checks only what the mise x mock logs. The mock never executes the target, and the wrapper directory is not on the test PATH. A self-exec loop under the PATH ordering this change targets would therefore go undetected. A bounded execution test with the wrapper ahead of the install directory would cover that risk.
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!
|
Checked Greptile's three inline findings against the source at the same head (23b8366), and Codex Medium reviewed them separately. Nothing on the branch has changed since the review above, so the worker results there still stand.
Still waiting on the maintainer: whether this lands as it is, or with a migration for installed wrappers and a different fallback. |
quattro's default-agent test gained an `ls` branch in its mise mock for the npm Grok migration, beside this branch's `which` branch; both are kept. quattro now installs Grok as mise's first-party `grok`, which the resolved-path assertion already uses. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Re-checked on a disposable Omarchy worker at 32a83d9. I reran the reproduction with real Second opinion: Codex Medium reviewed the merge and found nothing new. Its independence is not guaranteed. It confirmed that both mock branches survive. It found that nothing The two points from the earlier review are still open and unchanged by this merge. Wrappers already on users' machines are not regenerated. When Waiting on the maintainer: whether this lands as it is, or with a migration for installed wrappers and a different fallback. |
quattro dropped OMARCHY_TEST_MISSING_COMMAND from the install/user/mise.sh source line in default-agent-test.sh when Kimi became a selectable agent (omacom#7261); take its line and keep this branch's resolved-path assertion above it. quattro's new kimi-agent-test.sh expects the wrapper to call mise twice; the wrapper now asks `mise which kimi` in between, so the expected sequence includes it. Co-Authored-By: Claude Opus 5.5 <[email protected]> Co-Authored-By: Codex Medium <[email protected]>
|
Your code in Re-checked on a disposable Omarchy worker at 9f29a48. The reproduction used real Second opinion: Codex Medium reviewed the merge over two rounds. In the first it found the Kimi test failure above. In the second it found nothing more. It checked the scripts and tests on The two points from the earlier reviews are still open, and this merge does not change them. Wrappers already installed on users' machines are not regenerated. When Waiting on the maintainer: whether this lands as it is, or with a migration for installed wrappers and a different fallback. |
|
What #9596 changed. Omarchy's default CLI tools are now declared as mise lazy tools in Checked on a disposable Omarchy worker against
Why it shouldn't land as it is. Migrations still pending on a 4.0.x machine (1787215824 for Second opinion: Codex Medium and muse-wonder (via pi, thinking high) reviewed this with the same questions, statically. Both confirmed the cleanup regression from the migration code. Codex recommends closing this as superseded by #9596. muse-wonder pointed out two cases #9596 does not cover. First, Nothing was pushed to your branch this time. Waiting on the maintainer to decide between closing this as superseded by #9596, with the |
4480a142moved the generated stubs fromexec "$bin"toexec mise x "$package" -- "$bin"so the tool would resolve from mise's installdir rather than by name through PATH. That narrowed the loop but did not close
it: mise still looks the bare name up in PATH, so it can find the stub again
and exec itself forever, in the same PID, pinning a core.
Reproducing
Four conditions, all required:
~/.local/binprecedes the tool's mise install dir onPATH;PATH— otherwisemise xprepends it andthe name resolves correctly;
~/.local/share/mise/shimsis onPATH;__MISE_DIFF,__MISE_SESSION,MISE_SHELL).Condition 4 is why this hides: from an interactive shell (session vars set) the
same command returns in ~50ms. Only non-interactive children hit it — a systemd
service, a git subprocess, an agent runner.
Verified minimal by delta-debugging a 31-entry
PATHcaptured from a real stuckprocess; dropping any one of conditions 1-3 fixes it:
PATHwrapper : install : shimswrapper : install(no shims)wrapper : shims(no install dir)wrapperaloneinstall : shims : … : wrapper(wrapper last)Impact
Hit on Omarchy 4.0.2-1 as
gh auth git-credential getspinning for 85 minutesand burning 35 minutes of CPU, with the git operation behind it hung the whole
time — git had invoked the
ghstub as itscredential.helper. The same loopbroke an agent runner's tool probes: each probe spawned a stub, spun, and was
killed on timeout, so it dropped all three of its providers.
argv alternates on a single PID, no children, state flipping S/R:
The change
Resolve the binary with
mise whichand exec that absolute path, so the name isnever handed back for lookup. When resolution fails the stub falls back to the
previous line, keeping today's behavior rather than breaking a tool mise cannot
locate.
Generating a stub from the patched script in an identical sandbox: 62ms
instead of hanging. Generating one from
mainin that same sandbox still loops,so the before/after is attributable to this change alone.
Tests
test/shell.d/default-agent-test.shasserted the stub called mise exactly twice,which encoded the old contract; updated for the
mise whichcall, with the misemock taught to answer
which. Addedassert_stub_execs_resolved_path, whichfails against
mainand passes here../test/allshows the same 4 failures before and after this change(
omarchy-pkgscheckout missing ×3, and a widget IPC handler count) — allenvironmental on my machine, none related.