Skip to content

Symlink mise tools so argv[0] survives exec -a - #8133

Closed
chessing234 wants to merge 2 commits into
omacom:quattrofrom
chessing234:fix/mise-symlink-preserves-argv0-pr
Closed

chessing234 wants to merge 2 commits into
omacom:quattrofrom
chessing234:fix/mise-symlink-preserves-argv0-pr

Conversation

@chessing234

@chessing234 chessing234 commented Aug 25, 2026 •

Copy link
Copy Markdown
Contributor

withdrawing this direct-symlink approach: an isolated test with real mise 2026.9.18 kept running jq 1.7.1 after selecting 1.8.1, then left a dangling launcher after uninstalling 1.7.1. the nested-path fix is insufficient, the moving-alias test only modeled the desired behavior, and existing quiet wrappers still lack an upgrade migration; no claim that the upgrade path is fixed remains.

Copilot AI balanced review requested due to automatic review settings August 25, 2026 02:35

Copilot AI left a comment

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.

Pull request overview

Replaces mise shell wrappers with direct binary symlinks to preserve argv[0].

Tip

If you aren't ready for review, convert to a draft PR.
Click "Convert to draft" or run gh pr ready --undo.
Click "Ready for review" or run gh pr ready to reengage.

Changes:

  • Resolves installed binaries using mise where.
  • Adds argv[0], failure-path, and symlink tests.
  • Updates migration and agent tests for symlinks.

Reviewed changes

Copilot reviewed 3 out of 4 changed files in this pull request and generated 1 comment.

File Description
bin/omarchy-mise-install Replaces wrappers with binary symlinks.
test/shell.d/mise-install-test.sh Tests installation and argv[0] preservation.
test/shell.d/mise-wrapper-quiet-migration-test.sh Verifies wrapper-to-symlink migration.
test/shell.d/default-agent-test.sh Adapts agent fixtures to symlinks.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread test/shell.d/mise-install-test.sh Outdated
Comment on lines +105 to +107
if grep -q ' x ' "$mise_log"; then
fail "installer no longer re-execs through mise x"
fi

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

right, the stub logs $* so mise x would show up as a leading x, not a spaced one. the check is on the first field now.

@chessing234

Copy link
Copy Markdown
Contributor Author

@dhh @ryanrhughes ready for review

Shell wrappers re-exec through mise x, so multi-call binaries lose the
invocation name Claude Code relies on for ugrep. Link the real binary
instead, keep command-name guards, and teach remove-preinstalls to drop
Omarchy's absolute mise symlinks while leaving Cursor's relative ones.
@chessing234
chessing234 force-pushed the fix/mise-symlink-preserves-argv0-pr branch from 2fda5f4 to a817116 Compare September 12, 2026 03:48
@omarchybot omarchybot added the bug Something isn't working label Sep 27, 2026
@omarchybot

Copy link
Copy Markdown
Collaborator

Reviewed at a817116 on a disposable Omarchy worker, with real mise (2026.9.11) in a throwaway HOME.

The bug from #8120 is real, and this fixes it for claude. On quattro, (exec -a ugrep ~/.local/bin/claude -G -I "alias cx" …/default/bash/aliases) fails with error: unknown option '-G'. Through this branch's symlink the same call finds the alias, and claude --version still answers 2.1.283 (Claude Code).

It breaks most of the other tools it installs, and with them a fresh install.

  • bin/omarchy-mise-install:44 links $(mise where "$package")/$bin, but most packages do not keep their binary at the root of the install directory. With real mise, mise which --tool puts them at codex/…/bin/codex, gh/…/gh_2.101.0_linux_amd64/bin/gh, npm-playwright/…/node_modules/.bin/playwright and aqua-modem-dev-hunk/…/hunkdiff-linux-x64/hunk. For all four, omarchy-mise-install exits 1 and writes nothing. Of the six I tried, only claude and hey worked.
  • install/user/mise.sh runs under bash -eE (run_logged in install/helpers/logging.sh), and codex is its first install. On quattro that step exits 0 and lays down all 19 launchers. On this branch it exits 1 after 3 seconds, and ~/.local/bin is empty.
  • The tests don't catch this because their mise where stubs put every binary at the root.

It also changes more than #8120 asks for. These launchers are lazy: manual/17-ai.md promises that "nothing is downloaded until the first time you actually run one". Running mise use -g at install time downloads every default agent CLI during installation and in each migration that calls the script, including the ones a user never runs. The link also points at a versioned directory (installs/claude/2.1.283/claude), not mise's latest. install/user/mise.sh turns off upgrade.auto_prune, so after mise up in omarchy update the link keeps running the old version. Switching to mise which --tool "$package" "$bin", which resolves through latest/, would fix the path and the pinning. Whether the launchers should stop being lazy, even for the tools nobody calls under another name, is a decision for the maintainer rather than a defect to patch here. The issue itself suggested symlinking only the tools that need it.

Related: #9596 replaces these wrappers with mise's native lazy shims, and #13090, #8692 and #9583 each rewrite the same wrapper line to fix the exec loop. None of them preserves argv[0], so this is the only open fix for #8120, but it collides with all four.

What ran: mise-install-test.sh, mise-wrapper-quiet-migration-test.sh and default-agent-test.sh pass on both base and head, plus the real-mise runs above. This was reviewed by Claude Opus 5.5 alone. Codex Medium was configured as the second opinion but did not run, because today's review budget was spent. Nothing was pushed. This now waits on the maintainer to decide whether the launchers should stay lazy, and on the author for the path resolution.

@greptile-apps

greptile-apps Bot commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 3/5

[Medium risk] Changes how tool wrappers are installed and removed.

The PR is not ready to merge because existing users retain the broken wrappers and Remove Preinstalls can delete user-managed launchers.

Findings

  1. P1 Existing wrappers remain broken ▶
  2. P1 User launchers get deleted ▶
  3. P2 Upgrade test assumes moving paths ▶

Summary

The PR replaces mise-backed shell wrappers with direct executable symlinks to preserve forged argv[0], and updates preinstall removal and shell tests accordingly.

  • Existing --quiet wrappers are not converted on update, leaving the reported failure in place for existing users.
  • Preinstall removal can delete user-managed absolute symlinks.
  • The upgrade test assumes, rather than verifies, a moving path from real mise.

Reviews (1) · Last reviewed commit: "Resolve mise executable paths through th..."

Comment thread bin/omarchy-mise-install
Comment on lines +40 to +46
target=$(mise which --tool "$package" "$bin") || exit 1
if [[ ! -x $target ]]; then
exit 1
fi

rm -f "$HOME/.local/bin/$command"
ln -sf "$target" "$HOME/.local/bin/$command"

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.

P1 Existing wrappers remain broken Existing installations already have the previous --quiet shell wrappers. This change creates symlinks only when the installer runs again; normal updates do not rerun user provisioning, and migration 1787573629.sh skips --quiet wrappers. Users who update therefore keep wrappers that lose the forged argv[0], so the Claude Code grep failure persists. These wrappers need a migration to symlinks.

Comment on lines +23 to +26
if [[ -L ~/.local/bin/cursor-agent ]]; then
cursor_target=$(readlink ~/.local/bin/cursor-agent)
if [[ $cursor_target == /* ]]; then
rm -f ~/.local/bin/cursor-agent

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.

P1 User launchers get deleted If a user-managed cursor-agent or muse launcher is a symlink to an absolute executable path, Remove Preinstalls treats it as an Omarchy install and deletes it. The previous check preserved symlinks, and an absolute target does not establish who owns the launcher.

Comment on lines +109 to +123
for layout in bin/codex gh_2.101.0_linux_amd64/bin/gh hunkdiff-linux-x64/hunk; do
name=${layout##*/}
seed_tool "$name/v1" "$layout"
ln -s v1 "$installs/$name/latest"
MISE_TARGET="$installs/$name/latest/$layout"
run_install "$name" "$name"
[[ $(readlink "$home/.local/bin/$name") == "$MISE_TARGET" ]] ||
fail "$name retains mise's complete executable path"
seed_tool "$name/v2" "$layout"
rm "$installs/$name/latest"
ln -s v2 "$installs/$name/latest"
rm "$installs/$name/v1/$layout"
[[ $(invoke_argv0 "$home/.local/bin/$name" ugrep) == "ugrep" ]] ||
fail "$name follows mise's updated version alias"
done

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 Upgrade test assumes moving paths The mise stub returns a hand-built latest symlink path, so this test passes without checking whether real mise which --tool returns a path that moves with upgrades. The installer stores that path unchanged, and mise up does not refresh launchers. A real-mise upgrade check would catch launchers that remain on an old version or dangle if that version is removed.

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!

@omarchybot omarchybot removed the bug Something isn't working label Sep 30, 2026
@omarchybot

Copy link
Copy Markdown
Collaborator

Looked again at 19ca4ad by reading the new commit. Nothing ran on a worker this round.

The path resolution is fixed. bin/omarchy-mise-install:40 now finds the target with mise which --tool "$package" "$bin". That is the resolution the last review suggested for codex, gh, playwright and hunk, whose binaries do not sit at the root of the install directory. This round did not re-run it against real mise.

Two problems are still open, both found by reading this commit:

  • Machines that already have wrappers keep the bug. Nothing in this pull request rewrites them, and migrations/1787573629.sh only regenerates wrappers written before --quiet, so every current wrapper stays as it is. On an existing install, mise tool wrappers reset argv[0], so multi-call binaries lose their alternate mode (Claude Code's built-in grep silently finds nothing) #8120 stays unfixed for a tool until something runs omarchy-mise-install for it again. Greptile raised this too.
  • bin/omarchy-remove-preinstalls:23 and :35 now delete cursor-agent or muse whenever it is a symlink with an absolute target. quattro keeps every symlink at those paths. The new check is safe only if Cursor's installer, and anything else a user points those names at, always makes a relative link. I did not check Cursor's installer.

The classification is unsettled, so this item has no class label. I read it as a bug fix, because #8120 is behaviour that is wrong on quattro. Codex Medium, asked the same question separately and without my answer, called it an enhancement. The pull request does change behaviour on purpose, which supports that reading: launchers stop being lazy, and mise use -g now downloads each tool when its link is made rather than the first time it runs. The pull request itself leaves that choice to the maintainer, and the bug label stays off until it is made.

This is waiting on the maintainer. Whether launchers should install eagerly, for every tool or only for the ones called under another name, decides both what this pull request is and whether it needs the migration above.

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.

3 participants