Skip to content

Keep omarchy-mise-install from deleting files it did not write - #14539

Open
omarchybot wants to merge 1 commit into
quattrofrom
fix/issue-7101
Open

omarchybot wants to merge 1 commit into
quattrofrom
fix/issue-7101

Conversation

@omarchybot

Copy link
Copy Markdown
Collaborator

omarchy update deletes files a user keeps in ~/.local/bin under the names Omarchy installs mise wrappers for: claude, codex, gh, copilot, opencode, grok, hey, basecamp and the rest of install/user/mise.sh. Migration 1786183928 runs omarchy-refresh-applications, which reruns install/user/mise.sh, and omarchy-mise-install removed whatever was at each path before writing its wrapper. A hand-written wrapper that pins a version or points a tool at a proxy was replaced without a prompt or a backup, and snapper's default root config does not cover /home. omarchy-provision-user, omarchy-install-preinstalls and omarchy-upgrade-to-quattro reach the same code.

omarchy-mise-install now replaces the path only when it is empty, a symlink, or a wrapper Omarchy wrote. A symlink is still unlinked rather than written through, as #6619 chose, so its target is untouched. A wrapper counts as Omarchy's only when the whole file matches, byte for byte, one of the five forms the generator has written, with the package and binary as plain double-quoted words. That is the same test migration 1787573629 uses to decide which wrappers to regenerate. Anything else, including an Omarchy wrapper someone added a line to, is left in place with a note on stderr. The installer still exits 0 in that case, so an update carries on.

On a worker built from the Omarchy ISO, with a user's own claude and gh wrappers and an old-form Omarchy codex wrapper in a throwaway HOME, migration 1786183928 replaced all three on quattro. With this change it leaves the two user files as they were and still moves codex to the current form. The new cases in test/shell.d/mise-install-test.sh fail on quattro and pass here. Codex at medium effort reviewed the change over four rounds. It found that an earlier line-by-line match accepted edited wrappers, and that reading the file into a variable hid NUL bytes. Both are fixed here, and its last round found nothing.

Fixes #7101

Updates rerun every mise install through omarchy-refresh-applications, and the
installer removed whatever sat at ~/.local/bin/<command> before writing its
wrapper, so a user's own wrapper or binary at gh, claude or any of the other
names was deleted with no backup. Replace only a symlink or a wrapper Omarchy
wrote, matched byte for byte against each form the generator has had, and
leave anything else with a note.

Fixes #7101

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

greptile-apps Bot commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

[Medium risk] Changes file deletion logic in a shell installer script.

The PR appears safe to merge.

What we checked:

  • Edited wrappers survive updates: omarchy_wrapper requires the entire file to match a known form byte for byte. Extra lines or NUL bytes prevent replacement.
  • Symlink targets stay untouched: The installer removes the symlink before writing the wrapper. It does not write through the link.

Summary

omarchy-mise-install now preserves existing files unless they are symlinks or match a complete known Omarchy wrapper.

  • The installer compares whole files as bytes, so added lines and NUL bytes cannot pass unnoticed.
  • Preserved files produce a note without stopping the update.
  • Tests cover user files, edited wrappers, historical forms, scoped packages, FIFOs, and symlinks.
Diagram
%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Choose wrapper path] --> B{Existing non-symlink?}
  B -->|No| D[Remove path and write wrapper]
  B -->|Yes| C{Whole file matches a known wrapper?}
  C -->|Yes| D
  C -->|No| E[Leave file unchanged and print note]
Loading

Reviews (1) · Last reviewed commit: "Keep omarchy-mise-install from deleting ..." · Reviewed by Greptile

@jandrusk

jandrusk commented Oct 8, 2026

Copy link
Copy Markdown

Heads up: #11484 ("Preserve custom launchers when installing mise wrappers") and #13243 ("Stop mise-install from clobbering a user's own wrapper") are both still open for the same problem (#7101). This version's whole-file match against every historical wrapper form looks like the most careful of the three, but it's worth consolidating so omarchy-mise-install doesn't get three competing guards.

@charlielockyer-rice

Copy link
Copy Markdown

I moved Codex and Claude Code to their native installers. Both put a symlink at ~/.local/bin/<name>, and this PR still replaces symlinks, so those installs would get swapped back to mise wrappers. Could symlinks pointing outside mise's dirs be treated as the user's own install, like omarchy-default-agent already does?

@omarchybot

Copy link
Copy Markdown
Collaborator Author

I compared this pull request with the two older open fixes for #7101: #11484 and #13243. All three stop bin/omarchy-mise-install from deleting a hand-written launcher. #11484 is the one that should go forward, not this one. Nothing was run for this review, because only the fix going forward is tested on a worker.

The oldest fix wins by default, unless a newer one handles a case the older one misses. This one doesn't, and #11484 handles two cases this one gets wrong at dd8ee5f:

  • A symlink at the launcher path is still replaced (bin/omarchy-mise-install:87). @charlielockyer-rice is right: Claude Code's and Codex's native installers link ~/.local/bin/claude and ~/.local/bin/codex, and this branch swaps those back to mise wrappers on the next update. Preserve custom launchers when installing mise wrappers #11484 keeps a symlink in place.
  • A wrapper whose package the user changed is still replaced. This branch takes any wrapper in a generated form as Omarchy's, whatever package it names, so pinning "claude" to "claude@2.0.1" is undone on the next update. Preserve custom launchers when installing mise wrappers #11484 only replaces a wrapper that matches what it would write for the package being installed. It handles Omarchy's own package move for Grok in its migration.

This branch also exits 0 when a directory or FIFO is in the way, which leaves no command and reports success. #11484 and #13243 both fail in that case. I found nothing here that #11484 lacks: it already compares whole files as bytes.

All three conflict with test/shell.d/mise-provision-test.sh, which #7261 added to quattro on October 14. That test requires provisioning to replace a user's script, binary or symlink at ~/.local/bin/kimi, cursor-agent and muse, which is the behaviour #7101 asks to stop. Whichever fix lands has to change that test, and which way it goes is the maintainer's call.

Codex Medium gave the second opinion. I didn't tell it which fix I preferred, and it picked #11484 for the same reasons. It found the directory and FIFO case on its own. Independence is not guaranteed, because it can read this session's transcript.

This waits on the maintainer to pick between the three fixes and to decide what mise-provision-test.sh should require. If #11484 goes forward, this one can be closed.

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 update destroys user binaries in ~/.local/bin at 13 fixed names, including gh and claude

3 participants