Skip to content

Resolve mise wrapper binaries to absolute paths - #13090

Closed
surim0n wants to merge 2 commits into
omacom:quattrofrom
surim0n:fix/mise-exec-loop
Closed

surim0n wants to merge 2 commits into
omacom:quattrofrom
surim0n:fix/mise-exec-loop

Conversation

@surim0n

@surim0n surim0n commented Sep 24, 2026

Copy link
Copy Markdown
Contributor

Fixes #13040.

When a generated mise wrapper ran under a PATH that had ~/.local/bin before
mise's shims, mise x left PATH order untouched and the wrapper resolved
<bin> back to itself, exec'ing forever in the same PID.

  • mise which --tool <package> <bin> resolves the real install path
  • The wrapper execs that absolute path instead of a bare name

Tested:

  • test/shell.d/mise-install-test.sh verifies the wrapper calls mise which
    and execs the returned absolute path
  • Existing quoting and refusal behavior unchanged

Generated with Devin

When mise shims sat after ~/.local/bin on PATH, `mise x` did not reorder
PATH, so a generated wrapper resolved `<bin>` back to itself and exec'd in a
loop forever. `mise which --tool` returns the real install path, so exec
that instead.

Fixes omacom#13040.

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@llstrk

llstrk commented Sep 25, 2026

Copy link
Copy Markdown

Automated AI review

Community review: Independent automated community review, unaffiliated with the Omarchy team, intended to help prepare PRs for their review.

Verified: the new wrapper form stops the self-exec loop from #13040 for newly generated wrappers. Two gaps remain: wrappers already installed on user machines are not upgraded, and two existing shell tests still assert the old exec line. A third, narrower behavior change is noted below.

Packaged mise binary (offline, synthetic node install), inherited PATH ~/.local/bin : <tool path mise computes> : <mise shims> : /usr/bin, 8 s timeout:

                 base wrapper                     head wrapper
mise calls       669 (use, x, use, x, ...)        3 (use, which --tool, x)
exit             124 (timeout)                    0
program run      the wrapper itself               <install>/bin/node

Verified in the same setup and in mise source (2026.9.4 run; lookup logic unchanged through 2026.9.12):

  • An absolute program path skips mise x's PATH lookup, so the wrapper can no longer select itself.
  • Ordinary PATH layouts still run the real binary.
  • If a package no longer provides the bin name, the head wrapper exits with mise's is not a mise bin error. The base wrapper looped in that case even under an ordinary PATH.
  • Generated wrappers for every install/user/mise.sh call-site shape pass bash -n. Package names with shell characters stay one argument, and user arguments are preserved.
  • bin/omarchy-default-agent, bin/omarchy-remove-preinstalls and the migrations that detect wrappers key on the unchanged mise use -g --quiet line, so they still recognize the new form.
  • The updated mise-install-test.sh passes at head and fails against the base generator.

Existing wrappers keep the looping exec line

The PR changes only the generator. Nothing regenerates wrappers already in ~/.local/bin:

omarchy update
  run pending migrations
    1787573629.sh   matches only pre-`--quiet` forms       -> current wrapper unchanged
    1784909971.sh   matches only the older bare-exec form  -> current wrapper unchanged
  install/user/mise.sh (regenerates wrappers)               -> not called by the update path

A wrapper written by the current generator was byte-identical after running both migrations at the PR head. install/user/mise.sh is reached through provisioning, preinstall and upgrade paths, not omarchy update.

Impact: the machines that hit the loop in #13040 (for example claude and codex, and copilot as started by Hermes Desktop) keep exec mise x "<pkg>" -- "<bin>" "$@" after updating, so the reported loop persists there.

Suggested change: add a migration that regenerates wrappers exactly matching the current form (mise use -g --quiet "<pkg>" || exit 1 followed by exec mise x "<pkg>" -- "<bin>" "$@") through omarchy-mise-install, following the pattern of migrations/1787573629.sh and leaving customized files alone, plus a test for it.

Two existing shell tests still assert the old exec line

Test-suite only, not a production defect. Both pass at base and fail at head:

Test Result at head
test/shell.d/mise-wrapper-quiet-migration-test.sh not ok - migration keeps a wrapper's bin name when the command name differs (lines 74, 78, 90 and 94 grep for exec mise x "<pkg>" -- "<bin>" "$@")
test/shell.d/default-agent-test.sh not ok - grok lazy stub preserves its mise package (line 140 expects x as the second mise call)

In default-agent-test.sh, the mock mise answers which with no output and exit 0, so the wrapper runs x <pkg> -- --version with an empty program. fail exits at the first lazy-stub assertion (line 144), so the remaining lazy-stub checks and the rest of the file no longer run.

Suggested change: have the default-agent-test.sh mock print a path for which and assert the use, which --tool <pkg> <command>, x <pkg> -- <path> --version sequence. Update the quiet-migration greps to the new bin_path=$(mise which --tool ...) and exec mise x "<pkg>" -- "$bin_path" "$@" lines.

A project-pinned version that is not installed now stops the wrapper

Narrow behavior change. mise which --tool <pkg> with an unversioned package resolves the version the current directory configures and never installs. mise x <pkg> converts that pin into an explicit request and installs it when missing.

directory mise.toml pins node = "18.0.0" (not installed)
  base:  mise x node -- node               -> starts installing [email protected], then runs it
  head:  mise which --tool node node       -> "[email protected] is not installed", exit 1

Observed offline for head; for base, the install attempt was observed and online success is inferred from mise source.

Impact: running a wrapped CLI from a project that pins the same tool through mise at a version not yet installed (for example npm:playwright) now exits with an error instead of letting mise x install that version.

Suggested change: either accept and document this, or retry after mise install <pkg> when mise which fails. A plain fallback to the old mise x ... -- <bin> form would bring the self-exec loop back for the missing-bin case above.

Optional test improvement: the updated mise-install-test.sh stub never runs a program, so it checks the call shape rather than the loop. A synthetic stub mise that resolves a bare program through inherited PATH order and trips a loop guard separates the two templates: base tripped the guard after 51 use/x pairs, head ran the target once.

Related, outside this diff: the Hermes CLI wrapper written by bin/omarchy-install-hermes-cli (exec env -u UV_PYTHON mise x '$tool' -- hermes "$@") uses the same bare-name exec. Source inspection only; not reproduced.


Review information

Test scope: Pinned head c8a7f2c against base 28ceaae. Packaged mise 2026.9.4, offline, with a synthetic node install and private mise directories; relevant mise 2026.9.12 source compared with no lookup change. mise-install-test.sh and mise-wrapper-quiet-migration-test.sh run at base and head in isolation; default-agent-test.sh run through its first lazy-stub checks (lines 1-150). The remaining default-agent-test.sh impact is from source reading. The npm, github, aqua, http and pipx backends were assessed by source inspection only. No network installs, no real user wrappers, no desktop session.

AI process: Opus 5.5 Medium coordination and synthesis; independent Opus 5.5 Xhigh and GPT 6 Sol Xhigh technical assessments, with claims cross-checked against source and sealed isolated runs; Opus 5.5 Medium editorial check.

Opt out: To stop receiving these reviews, reply to this comment saying so.

@surim0n

surim0n commented Sep 25, 2026

Copy link
Copy Markdown
Contributor Author

Thanks, this was a thorough one. In b0ebcec:

  • Both existing tests are updated to the new wrapper form, and the default-agent-test.sh mock now answers which with a path and asserts the use → which --tool → x <path> sequence.
  • New migration 1790343618.sh regenerates wrappers that exactly match the previous generator output through omarchy-mise-install, following 1787573629.sh; customised files are left alone. Covered by mise-wrapper-resolution-migration-test.sh.
  • The project-pinned-but-not-installed case: accepted as is. mise which failing loudly there seems preferable to a fallback that reintroduces the self-exec loop; happy to add a mise install retry if the maintainers would rather keep the old auto-install behaviour. The Hermes wrapper has the same bare-name exec and is worth a separate change.

@llstrk

llstrk commented Sep 27, 2026

Copy link
Copy Markdown

Automated AI review

Community review: Independent automated community review, unaffiliated with the Omarchy team, intended to help prepare PRs for their review.

Follow-up on b0ebcec, reassessing the earlier review after the author's reply.

Verified: the new migration upgrades existing wrappers, and both previously failing tests pass. One newly found, narrow behavior difference in the mise which --tool lookup (present since c8a7f2c) is described below. It also qualifies the earlier project-pin point.

Earlier point Status at b0ebcec
Existing wrappers keep the looping exec line Resolved by migrations/1790343618.sh
Two shell tests assert the old exec line Resolved
Uninstalled project-pinned version stops the wrapper Still present, accepted by the author. Now reaches existing installs too; see the qualification below
Optional loop-guard test for mise-install-test.sh Unchanged, still optional
Hermes CLI wrapper uses the same bare-name exec Resolved upstream by #12844 (merged into quattro after the earlier review), which retires the mise-backed Hermes wrapper through migrations/1790017600.sh

Verified in isolated runs with the real generator and a logging stub mise:

  • For every install/user/mise.sh call site, including the Muse http: package, a wrapper written by the previous generator was regenerated byte-identical to what omarchy-mise-install writes today. Scoped npm names, @version suffixes, a bin name that differs from the command name, and names with spaces or ;&|*?[]'~#%=, also round-trip, with every argument reaching mise intact. Names the generator escapes (containing $, backticks, quotes, backslashes or !) are left unmigrated; no Omarchy call site uses them.
  • Wrappers from every generator version quattro shipped end in the current form after 1784909971, 1787573629 and 1790343618 run in order.
  • The migration leaves alone:
    • wrappers with an added line;
    • symlinks, FIFOs, directories, unreadable files and large binaries;
    • unrelated scripts;
    • wrappers already in the new form (not rewritten).
  • A missing, empty or symlinked ~/.local/bin exits 0. The migration makes no mise calls, so offline updates are unaffected.
  • mise-wrapper-quiet-migration-test.sh and default-agent-test.sh fail at c8a7f2c and pass at b0ebcec, and default-agent-test.sh runs all 48 checks again. The new mise-wrapper-resolution-migration-test.sh passes, and fails when the generator is swapped back to the base version.
  • With current quattro merged in, all four wrapper tests pass.

mise which --tool <pkg> can return another tool's executable

Without a version, --tool <pkg> does not limit the lookup to <pkg>. mise which returns the first installed, active mise tool that ships <bin>, in mise's own order: project config first, then global config in file order. The old mise x <pkg> -- <bin> put <pkg>'s bin directory first among the directories mise adds to PATH. This is from mise 2026.9.12 source (src/cli/which.rs 108-117, src/toolset/builder.rs 293-326, src/toolset/mod.rs 694-711).

Packaged mise 2026.9.4, offline, with synthetic npm: tools toola and toolb that both ship shared. The wrapper was generated for npm:toolb shared and run by absolute path:

situation                                          base wrapper     head wrapper
global config lists toola before toolb             runs toolb       runs toola
global has toolb, project mise.toml adds toola     runs toolb       runs toola
toolb listed first (control)                       runs toolb       runs toolb
project pins toolb to an uninstalled version       (installs pin)   (installs pin), then execs toola's path

mise which --tool npm:toolb onlya even returned toola's onlya, a name toolb does not ship. Running the wrapper's mise use -g did not move its package ahead of toola. In the pin row, mise which returned toola's path with exit 0; both wrappers then started installing the pin in mise x (offline, so the final exec of toola's path is inferred from source).

Impact: a wrapper can silently run a different install of the same CLI (for example npm:@anthropic-ai/claude-code next to Omarchy's claude), or an unrelated program with the same name (the registry cf is the Cloud Foundry CLI, while Omarchy's cf wrapper is the Cloudflare CLI). The last row qualifies the earlier project-pin point: the wrapper exits with is not installed only when no other active tool ships the name; otherwise it goes on to install the pin and then runs the other tool's binary. Exposure is low. Omarchy's own tools do not overlap, and Omarchy puts mise's shims ahead of ~/.local/bin, so the wrapper is reached mainly in #13040-style contexts or by direct path.

Suggested change: either accept and document this lookup order, or resolve the binary only within <pkg>. mise bin-paths <pkg> keeps only the requested tool (src/cli/bin_paths.rs 30-39). In the same run it printed only toolb's directory. For the uninstalled pin it printed nothing and exited 0, so a wrapper would need to treat empty output as failure. Open PR #8692 proposes this approach for the same loop (mise bin-paths plus an -x check) and adds a migration that matches the same previous wrapper form. The two PRs change the same generator line and the same test assertions.

Optional test improvement: in mise-wrapper-resolution-migration-test.sh, removing the migration's symlink guard or dropping the third argument to omarchy-mise-install still passes. The test's only symlink points at an already-migrated wrapper, and every case has the same bin and command name. A stale wrapper whose bin differs from its command name (like mise-exec-era in the quiet-migration test) and a symlink to a stale wrapper outside ~/.local/bin would catch both.


Review information

Test scope: Head b0ebcec against the earlier head c8a7f2c and base 28ceaae, plus b0ebcec with current quattro merged. The migration was run across 29 wrapper shapes, the generator versions quattro shipped, and filesystem edge cases, and the wrapper tests at each revision where they exist, with mutations of the new migration, all in isolation with no network. The lookup comparison used packaged mise 2026.9.4 with synthetic npm: tools; the relevant mise 2026.9.12 source was compared and has no lookup change. Other backends and the #13040 PATH layout combined with a collision were not run. In the project-pin case the install was only started offline; its completion and the following exec are inferred from mise source. No real user wrappers, no network installs, no desktop session.

AI process: Opus 5.5 Medium coordination and synthesis, Opus 5.5 Xhigh technical review and final fact check, GPT 6 Sol Xhigh search for related issues, Opus 5.5 Medium editorial check.

Opt out: To stop receiving these reviews, reply to this comment saying so.

@omarchybot

Copy link
Copy Markdown
Collaborator

Reviewed by Claude Opus 5.5, with Codex Medium as a separate second opinion. I did not run this on a worker, because another open pull request fixes the same loop in a way we think is better, and verifying a fix that will not be merged would not help anyone.

Competing fixes. Four other open pull requests change the same generator line to stop the self-exec loop in #13040: #8692, #13677, #13614 and #13769. We compared all five diffs. Both reviewers picked #8692 on their own.

Why #8692 over this one. This pull request resolves the binary with mise which --tool <pkg> <bin>. Without a version, that lookup is not limited to <pkg>: it returns the first active mise tool that ships <bin>, so the wrapper can exec a different tool's executable with the same name. The 27 September community review above showed this with two synthetic tools, and mise's src/cli/which.rs and src/toolset/builder.rs confirm it. #8692 instead searches the directories from mise bin-paths <pkg>, which mise filters to the requested package (src/cli/bin_paths.rs). It also refuses a bin name that contains a path, migrates wrappers that match the previous template, and merges cleanly into quattro. This branch currently conflicts with quattro. #13677 and #13769 have the same which --tool limitation. #13614 adds a re-entry guard, which stops the loop but does not fix the lookup.

What this pull request adds is worth keeping, whichever fix lands: the migration and the updated default-agent-test.sh and quiet-migration tests. Also, #8692 says it fixes #7234 and does not mention #13040, which is the same bug.

What happens next. Choosing between the competing fixes is up to the maintainer, so this one is waiting on them. You don't need to do anything for now.

@omarchybot

Copy link
Copy Markdown
Collaborator

Thank you for this, @surim0n. #8692 got there first with a fix for the same problem, so this is closed in favour of it, and the credit stays with the first fix. If it does not cover your case, please say so there.

Closed at the maintainer's request. The review comment above has the details; it was done by Claude Opus 5.5 with Codex Medium as a second opinion, whose agreement is not independent.

@omarchybot omarchybot closed this Oct 3, 2026
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.

omarchy-mise-install wrappers exec-loop forever when mise shims are on PATH after ~/.local/bin

3 participants