Skip to content

Preserve custom launchers when installing mise wrappers - #11484

Open
yashranaway wants to merge 13 commits into
omacom:quattrofrom
yashranaway:fix/preserve-custom-mise-launchers
Open

yashranaway wants to merge 13 commits into
omacom:quattrofrom
yashranaway:fix/preserve-custom-mise-launchers

Conversation

@yashranaway

@yashranaway yashranaway commented Sep 12, 2026 •

Copy link
Copy Markdown
Contributor

Updates leave someone's own launcher in place. Omarchy refreshes only exact wrappers it generated for the requested package and command; symlinks and edited package choices stay active. The Grok migration replaces its old generated wrapper before removing the npm tool, but keeps custom npm launchers and their tool.

Focused tests cover current and older wrappers, private permissions, symlinks, modified files, the Grok migration, and agent setup.

@llstrk

llstrk commented Oct 1, 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.

Outcome: Older wrappers Omarchy generated are also backed up, as executables on PATH that migration 1787573629 can turn into live wrappers.

Older generated wrappers are backed up on every template refresh

The backup condition at bin/omarchy-mise-install:72 compares only with the new template, so refreshing an older generated wrapper leaves a mode-755 <name>.bak.XXXXXX in ~/.local/bin (on PATH), and nothing removes it. If migrations/1787573629.sh is still pending, its rescan regenerates that backup as a live wrapper claude.bak.XXXXXX and backs it up again. Impact: one update from before 2026-08-08 leaves two noise files per default wrapper, and with #13090 or #13614 merged, their migrations back up every current generated wrapper.

Suggested change: replace regular files matching the current template or the forms listed in 1787573629.sh without a backup, and keep backups off PATH.

Reproducer: generated wrapper backup (fails at 36e3372)

Reproducer: refreshing a wrapper that omarchy-mise-install itself generated leaves an executable backup in ~/.local/bin

Save as test/shell.d/mise-install-generated-backup-test.sh and run bash test/shell.d/mise-install-generated-backup-test.sh from the repository root. It needs no mise (the wrapper is only written, never run).

#!/bin/bash

set -euo pipefail
source "$(dirname "${BASH_SOURCE[0]}")/base-test.sh"

test_tmp=$(mktemp -d)
trap 'rm -rf "$test_tmp"' EXIT
export HOME="$test_tmp/home"
bin_dir="$HOME/.local/bin"
mkdir -p "$bin_dir"

# The wrapper omarchy-mise-install itself wrote before --quiet, i.e. the
# cooldown-export form that migrations/1787573629.sh regenerates.
printf '#!/bin/bash\nexport MISE_MINIMUM_RELEASE_AGE=0\nmise use -g "claude" || exit 1\nexec mise x "claude" -- "claude" "$@"\n' >"$bin_dir/claude"
chmod 755 "$bin_dir/claude"

"$ROOT/bin/omarchy-mise-install" claude

ls -l "$bin_dir" | awk 'NR > 1 { print $1, $NF }'
leftovers=$(find "$bin_dir" -name 'claude.bak.*' -print)
[[ -z $leftovers ]] ||
  fail "refreshing a wrapper omarchy-mise-install generated leaves no backup on PATH" "$leftovers"
pass "refreshing a wrapper omarchy-mise-install generated leaves no backup on PATH"

Actual output at the PR head (36e3372), exit status 1. Stdout:

Saved existing launcher to /tmp/tmp.UHZJ1U8JOu/home/.local/bin/claude.bak.AxYPtD
-rwxr-xr-x claude
-rwxr-xr-x claude.bak.AxYPtD

Stderr:

/tmp/tmp.UHZJ1U8JOu/home/.local/bin/claude.bak.AxYPtD
not ok - refreshing a wrapper omarchy-mise-install generated leaves no backup on PATH

Actual output at the merge base (28ceaae), exit status 0, stdout (stderr empty):

-rwxr-xr-x claude
ok - refreshing a wrapper omarchy-mise-install generated leaves no backup on PATH
Reproducer: backup regenerated by migration 1787573629 (fails at 36e3372)

Reproducer: a saved backup is picked up by migration 1787573629 and regenerated as a live wrapper named claude.bak.XXXXXX, with a second backup of the backup

Save as test/shell.d/mise-install-backup-rescan-test.sh and run bash test/shell.d/mise-install-backup-rescan-test.sh from the repository root. It runs the repository's own migrations/1787573629.sh with bin/ on PATH, as omarchy-migrate would; nothing runs mise.

#!/bin/bash

set -euo pipefail
source "$(dirname "${BASH_SOURCE[0]}")/base-test.sh"

test_tmp=$(mktemp -d)
trap 'rm -rf "$test_tmp"' EXIT
export HOME="$test_tmp/home"
bin_dir="$HOME/.local/bin"
mkdir -p "$bin_dir"

# A wrapper as omarchy-mise-install wrote it from 2026-07-27 until migration
# 1786183928 arrived. On such a machine one `omarchy update` runs 1786183928
# (omarchy-refresh-applications -> install/user/mise.sh rewrites the wrapper by
# name) and then 1787573629, which scans ~/.local/bin/* for this same form.
printf '#!/bin/bash\nmise use -g "claude" || exit 1\nexec mise x "claude" -- "claude" "$@"\n' >"$bin_dir/claude"
chmod 755 "$bin_dir/claude"

"$ROOT/bin/omarchy-mise-install" claude
PATH="$ROOT/bin:$PATH" bash -euo pipefail "$ROOT/migrations/1787573629.sh"

find "$bin_dir" -mindepth 1 -printf '%f\n' | sort
for backup in "$bin_dir"/claude.bak.*; do
  [[ -e $backup ]] || continue
  grep -q -- '--quiet' "$backup" &&
    fail "a saved launcher is not regenerated as a live wrapper by a later migration" "$backup: $(cat "$backup")"
done
pass "a saved launcher is not regenerated as a live wrapper by a later migration"

Actual output at the PR head (36e3372), exit status 1. Stdout:

Saved existing launcher to /tmp/tmp.y4AmbITvP4/home/.local/bin/claude.bak.qOofqL
Regenerate mise wrappers that still print mise's own output to stdout
Saved existing launcher to /tmp/tmp.y4AmbITvP4/home/.local/bin/claude.bak.qOofqL.bak.KWMU2u
claude
claude.bak.qOofqL
claude.bak.qOofqL.bak.KWMU2u

Stderr:

/tmp/tmp.y4AmbITvP4/home/.local/bin/claude.bak.qOofqL: #!/bin/bash
export MISE_MINIMUM_RELEASE_AGE=0
mise use -g --quiet "claude" || exit 1
exec mise x "claude" -- "claude" "$@"
not ok - a saved launcher is not regenerated as a live wrapper by a later migration

Actual output at the merge base (28ceaae), exit status 0, stdout (stderr empty):

Regenerate mise wrappers that still print mise's own output to stdout
claude
ok - a saved launcher is not regenerated as a live wrapper by a later migration

The same happens through the real runner: omarchy-migrate with only 1786183928 and 1787573629 pending, on a home holding three wrappers in the form above plus one hand-written codex, ends with 7 *.bak.* entries at the head (the intended codex.bak.*, plus claude, gh and omp each as <name>.bak.X regenerated with --quiet and <name>.bak.X.bak.Y holding the old form) and 0 at the merge base, where codex is overwritten.

Details

Verified (at 36e3372, synthetic HOME):

  • A hand-written regular file, a symlink and a dangling symlink are saved verbatim with their mode before replacement; symlink targets are untouched.
  • An identical reinstall creates no backup.
  • A failed backup exits 1 with the original launcher intact and no staged file left behind.
  • The new test passes at the head and fails at the merge base; mise-install, quiet-wrapper migration, migrate-wrapper, Hermes CLI, preinstalls and default-agent tests pass at the head and on a local merge with the tip of the base branch quattro.

Optional notes:

  • Optional test improvement: backups=("$launcher".bak.*) without shopt -s nullglob has one element when no backup exists, so the "one backup is created" count cannot fail for zero (the next cmp assertion still catches it). Adding nullglob makes the count meaningful.
  • Optional test improvement: the symlink cases never compare readlink of the backup with the original link target, and "symlink target is untouched" compares against the first section's backup. A mutant that saves links pointing elsewhere passes all new assertions; comparing readlink output closes that.
  • New exit-1 paths (a directory at the launcher path, an unreadable file, an unwritable ~/.local/bin holding a writable launcher) now stop migrations that call omarchy-mise-install directly and the provisioning run of install/user/mise.sh, where the base exited 0. These are unusual inputs and the refusal is clearer, but the stale comment "Checked before anything is removed or written" (lines 17-22) and the short reflowed line there could be updated.

Cross-PR: a clean merge with #10168 fails the new test at grep -Fq 'mise use -g --quiet "tool"', because #10168 writes "tool@latest". #13470, #13677 and #13769 conflict textually in bin/omarchy-mise-install.

Other open PRs for this issue
  • Stop mise-install from clobbering a user's own wrapper #13243: refuses (exit 1) to replace an unrecognised regular file instead of backing it up, so the user's launcher stays active, but a migration that installs over such a file directly fails, and it and every later migration stay pending; it recognises generated wrappers by a single-line grep and conflicts textually with this PR.

Review information

Test scope: Source and sandbox tests with stubbed mise, at 36e3372; no real mise.

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.

@yashranaway

Copy link
Copy Markdown
Contributor Author

Confirmed both backup problems. Generated historical wrappers now refresh without backups, custom launchers are saved outside PATH, and the preservation and migration regressions pass.

@greptile-apps

greptile-apps Bot commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[High impact] The PR appears safe to merge; no outstanding finding or new actionable issue remains.

Summary

The PR preserves custom mise launchers while refreshing wrappers that match Omarchy’s generated templates. The Grok migration backs up an old generated launcher during replacement and restores it if installation fails; focused tests cover preservation, migration, and agent behavior.

Reviews (8) · Last reviewed commit: "Start the Kimi removal check from an emp..." · Reviewed by Greptile

Comment thread bin/omarchy-mise-install Resolved
Comment thread bin/omarchy-mise-install Resolved
@jandrusk

Copy link
Copy Markdown

Heads up on overlap: #13243 and #14539 also fix #7101 (stop omarchy-mise-install from deleting a launcher it didn't write), and #11514 rewrites the same wrapper template. It'd help the maintainer to pick one approach. Yours is the only one that also handles refreshing historical generated wrappers without leaving backups on PATH, which is worth calling out when comparing them.

@omarchybot

Copy link
Copy Markdown
Collaborator

Thanks for this. I reviewed it against quattro and against the two other open pull requests that fix #7101, #13243 and #14539. It merges cleanly, and the staging, permission handling and recognition of the older generated wrapper forms read correctly. Nothing was run for this review: when several fixes compete for one bug, only the one going forward is tested on a worker.

The reason it is not that one: bin/omarchy-mise-install still replaces a launcher it did not write. After the backup, the mv -fT at the end runs whatever was found, so a hand-written ~/.local/bin/claude that sets ANTHROPIC_BASE_URL still stops working on the next omarchy update. Its contents are kept in ~/.local/state/omarchy/mise-backups, and the only notice is one line in the update output. If the user puts their launcher back, the next migration that installs that name replaces it again. #7101 is that the update takes over a file the user owns. A backup makes that loss recoverable, but the takeover still happens. #13243 and #14539 leave a file they don't recognise as Omarchy's in place and exit 0, so migrations carry on and the user's launcher keeps working. That covers the case this change misses, so the policy of letting the earliest fix win by default doesn't apply here.

Codex Medium gave the second opinion on which fix should go forward. It reached the same conclusion: this pull request saves the launcher but still replaces the one the user runs. It agreed with a conclusion I had already reached, and its independence is not guaranteed. It also found two smaller problems here. A relative symlink copied into the backup directory no longer resolves from there. A generated-looking file with a NUL byte added is treated as generated and is replaced without a backup.

This now waits on the maintainer, who will choose among the three fixes.

Comment thread bin/omarchy-mise-install Resolved
@yashranaway

Copy link
Copy Markdown
Contributor Author

I changed this in 9dd25f6. Existing launchers now stay active unless they match Omarchy's wrapper for the requested package and command. That keeps relative symlinks, package edits, and NUL-modified lookalikes intact. Installer, migration, and agent tests pass.

Comment thread bin/omarchy-mise-install Resolved
Comment thread migrations/1790863209.sh Resolved
yashranaway and others added 2 commits October 15, 2026 05:53
The loop before it ends with the user's symlink at ~/.local/bin/kimi, which omarchy-mise-install now keeps, so the removal check was handed the user's link instead of Omarchy's wrapper.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Codex Medium <noreply@openai.com>
@omarchybot

Copy link
Copy Markdown
Collaborator

I reviewed the new head against quattro and ran it on a disposable worker. The earlier finding is fixed: bin/omarchy-mise-install now leaves a launcher it does not recognise in place and exits 0. A relative symlink and a NUL-modified lookalike are both kept.

What ran. I used a harness on the worker with a throwaway HOME (mise is never run). A hand-written ~/.local/bin/claude is replaced on quattro 246f33a and kept at this head, so #7101 is reproduced and fixed. Older generated wrappers are refreshed without leaving backups, and a symlink at the launcher path is kept. ./test/cli showed no failures. I also ran every test/shell.d test that touches ~/.local/bin, the installer or the affected migrations. All pass except two, and both of those pass on quattro:

  • test/shell.d/kimi-agent-test.sh:82 was a fixture problem. The loop before it leaves the user's symlink at ~/.local/bin/kimi, which this change now keeps. I pushed 5ebc58a, which clears the path first, and the test now passes.
  • test/shell.d/mise-provision-test.sh:31-46 came from Add Kimi as a selectable default coding agent #7261, which merged yesterday. It asserts that provisioning puts the wrapper back over a user's script, binary or symlink. That is the opposite of this change, so the maintainer needs to decide which policy holds before the test can be updated either way.

Found, at this head:

  1. The 3.x to 4 upgrade no longer replaces the 3.x launchers. omarchy-upgrade-to-quattro runs omarchy-refresh-applications, which runs install/user/mise.sh. That step relies on omarchy-mise-install overwriting the wrappers 3.x's omarchy-npm-install wrote for codex, copilot, opencode, pi, ghui and hunk. On the worker, quattro replaces a 3.x codex wrapper and this head keeps it. Upgraded machines would stay on pnpm dlx for all six, and hunk would stay on the old hunkdiff package. Stop mise-install from clobbering a user's own wrapper #13243 and Keep omarchy-mise-install from deleting files it did not write #14539 have the same gap.
  2. A generated wrapper for a different package is kept (bin/omarchy-mise-install:91). A generated oh-my-pi wrapper stays when github:can1357/oh-my-pi omp is requested, while quattro, Stop mise-install from clobbering a user's own wrapper #13243 and Keep omarchy-mise-install from deleting files it did not write #14539 rewrite it. That wrapper only existed on quattro for a few hours before beta3, so it matters little today. However, any later migration that moves a tool to a new package would quietly do nothing.
  3. The Grok migration retry can skip its cleanup (migrations/1790863209.sh:59). The wrapper is now replaced before the npm tool is dropped. If mise unuse or mise uninstall fails after that, the retry no longer sees an npm wrapper, so npm_stub is false. The removal of ~/.grok/bin/grok at line 77 is then skipped, and the old binary stays ahead of mise on PATH. quattro drops the npm tool first, so a retry still finds the wrapper. This only happens on a failure path.

Second opinion. Codex Medium reviewed it at 1717953. Finding 3 is its own. It also confirmed 1 and 2, and the kimi fixture fix I pushed, from results I had already given it, so that part is agreement and its independence is not guaranteed.

Competing fixes. We disagree on #11484 versus #13243 and #14539. Codex prefers #13243 because it handles the package switch in point 2. I would keep this one ahead, as the oldest. It is also the only one of the three that keeps a symlink at the launcher path; Claude's native installer, for example, links ~/.local/bin/claude. The package switch it misses affected only a few hours of pre-beta quattro. Codex also found that #13243 compares the file through a Bash variable, which drops NUL bytes. None of the three is ready as it stands.

This now waits on the maintainer to choose between the three fixes and to decide the mise-provision-test.sh policy. Points 1 to 3 then need fixing in whichever fix goes forward.

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