From 9e45f34f869acdc9778843e0c14f71a0e8c3d257 Mon Sep 17 00:00:00 2001 From: David Laing Date: Tue, 1 Sep 2026 10:44:57 +0100 Subject: [PATCH] Exec mise wrappers by resolved path, not by name MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 4480a142 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 --- bin/omarchy-mise-install | 11 ++++++++++- test/shell.d/default-agent-test.sh | 29 ++++++++++++++++++++++++++++- 2 files changed, 38 insertions(+), 2 deletions(-) diff --git a/bin/omarchy-mise-install b/bin/omarchy-mise-install index e6dfc96ca332..3a69c3917cfc 100755 --- a/bin/omarchy-mise-install +++ b/bin/omarchy-mise-install @@ -23,7 +23,16 @@ cat >"$HOME/.local/bin/$command" </dev/null) +if [[ -n \$resolved ]]; then + exec mise x "$package" -- "\$resolved" "\$@" +else + exec mise x "$package" -- "$bin" "\$@" +fi EOF chmod +x "$HOME/.local/bin/$command" diff --git a/test/shell.d/default-agent-test.sh b/test/shell.d/default-agent-test.sh index db964d90df5c..17c87083930a 100644 --- a/test/shell.d/default-agent-test.sh +++ b/test/shell.d/default-agent-test.sh @@ -61,6 +61,11 @@ if [[ $1 == "where" ]]; then exit fi +if [[ $1 == "which" ]]; then + [[ -n ${OMARCHY_TEST_MISE_WHICH:-} ]] && printf '%s\n' "$OMARCHY_TEST_MISE_WHICH" + exit +fi + [[ ${OMARCHY_TEST_MISE_FAIL:-false} != "true" ]] SH @@ -108,16 +113,38 @@ assert_lazy_stub() { "$test_home/.local/bin/$command" --version mapfile -t mise_calls <"$mise_history" - [[ ${mise_calls[0]} == "use -g --quiet $package" && ${mise_calls[1]} == "x $package -- $command --version" ]] || + # The stub resolves the binary to an absolute path before exec'ing it, so the + # name is never handed back to mise to look up through PATH. + [[ ${mise_calls[0]} == "use -g --quiet $package" && ${mise_calls[1]} == "which $command" && + ${mise_calls[2]} == "x $package -- $command --version" ]] || fail "$command lazy stub preserves its mise package" } +# A stub must never exec the bare command name when mise can resolve it: with +# ~/.local/bin ahead of mise's install dir on PATH, the name finds the stub +# again and it execs itself forever. +assert_stub_execs_resolved_path() { + local package=$1 + local command=$2 + + : >"$mise_history" + "$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" +} + assert_lazy_stub "$grok_package" grok assert_lazy_stub "$omp_package" omp assert_lazy_stub "$crush_package" crush assert_lazy_stub "$ori_package" ori pass "custom agent lazy stubs preserve their mise packages" +assert_stub_execs_resolved_path "$grok_package" grok +pass "lazy stubs exec the resolved binary path" + source "$ROOT/install/user/mise.sh" grep -Fx "$agy_package agy" "$stub_log" >/dev/null || fail "user setup creates the Antigravity lazy stub" grep -Fx "$grok_package grok" "$stub_log" >/dev/null || fail "user setup creates the Grok lazy stub"