Skip to content

Default OMARCHY_PATH in update-dev for sudo env_reset - #9966

Closed
fresh3nough wants to merge 1 commit into
omacom:quattrofrom
fresh3nough:fix/9953-update-dev-omarchy-path
Closed

fresh3nough wants to merge 1 commit into
omacom:quattrofrom
fresh3nough:fix/9953-update-dev-omarchy-path

Conversation

@fresh3nough

Copy link
Copy Markdown
Contributor

Summary

sudo omarchy update aborts right after the system snapshot with:

/usr/bin/omarchy-update-dev: line 7: OMARCHY_PATH: unbound variable
Something went wrong during the update!

omarchy-update-dev runs under set -euo pipefail and dereferences OMARCHY_PATH before anything else. sudo resets the environment, so the variable is unset on stock installs and the step kills the whole update before packages are upgraded.

Fix

Default a missing path to the packaged install, matching omarchy-migrate, omarchy-version, and the other privileged helpers:

OMARCHY_PATH="${OMARCHY_PATH:-/usr/share/omarchy}"

Stock installs still exit 0 immediately. Dev checkouts keep pulling when the path is set.

Fixes #9953

Test plan

  • bash test/shell.d/update-dev-test.sh — all cases pass, including new ones:
    • unset OMARCHY_PATH (sudo env_reset) skips without unbound-variable error
    • empty OMARCHY_PATH skips as stock
    • stock path still skips git
    • custom checkout still pull --ff-only
    • invalid checkout still fails with a useful error
    • no-upstream checkout still skips safely
  • bash test/shell.d/update-sequence-test.sh — update step order unchanged
  • Manual repro:
    • Before: env -u OMARCHY_PATH bin/omarchy-update-dev → OMARCHY_PATH: unbound variable (exit 1)
    • After: same command exits 0 with no git activity
    • Custom OMARCHY_PATH still runs git -C … pull --ff-only

sudo omarchy update aborts after the snapshot because omarchy-update-dev
dereferences OMARCHY_PATH under set -u while sudo env_reset leaves it unset.
Treat a missing path as the packaged install so stock updates continue.

Fixes #9953

Signed-off-by: fresh3nough <anonwurcod@proton.me>
@omarchybot

Copy link
Copy Markdown
Collaborator

Reviewed by Claude Opus 5 in Claude Code, with an independent second opinion from Codex (gpt-5.6-sol) at xhigh reasoning. The change is correct and the tests earn their place. Nothing pushed to your branch.

Ran test/shell.d/update-dev-test.sh on a disposable Omarchy worker VM at a944737: 7 passed, 0 failed. Then mutation-proved it by deleting the added OMARCHY_PATH="${OMARCHY_PATH:-/usr/share/omarchy}" line and re-running against the same tests, which fails with bin/omarchy-update-dev: line 10: OMARCHY_PATH: unbound variable — so the new assertions do fail on unfixed quattro rather than passing vacuously. Worth noting these live under test/shell.d/, which ./test/cli does not run; they need ./test/shell or ./test/all.

The empty-value case is the strongest thing here and no other change in this cluster covers it. On unfixed quattro OMARCHY_PATH= does not trip set -u at all, because the variable is set — it falls through to the dev branch, and git -C "" leaves the working directory unchanged rather than erroring, so the script operates on whatever repository the caller happened to be standing in. Reproduced on the worker against the unfixed script with the suite's stub git, which logged -C rev-parse --is-inside-work-tree, -C rev-parse --abbrev-ref --symbolic-full-name @{upstream}, then -C pull --ff-only. Under sudo omarchy update that is a fast-forward pull in the caller's cwd, as root. ${...:-...} closes it and your third assertion pins it.

One gap, and it is scope rather than a defect. bin/omarchy-update reaches omarchy-update-status, which calls omarchy-update-available inside an if, and that script carries the identical bare dereference at line 9. With your branch applied, on the worker, env -u OMARCHY_PATH bin/omarchy-update-available still prints bin/omarchy-update-available: line 9: OMARCHY_PATH: unbound variable and exits 1. So sudo omarchy update now runs to completion but still emits that line near the end. Codex worked out something I had not: the update indicator is not actually left wrong by this, because omarchy-shell -q bails on the same unset variable at bin/omarchy-shell:40 and its fail returns 0 silently under -q, so both the refresh and the clear branch are no-ops under sudo regardless. The residue is the stray error line, not a misleading widget. That is codex contributing a mechanism rather than agreeing with a conclusion; where it merely agreed with what was already written down, its independence is not currently guaranteed, and its claim that bash exits 127 on an unbound variable is wrong — measured exit status is 1, which does not change the branch taken.

Four open pull requests now address this cluster: #8590 (omarchy-update-dev, using : "${OMARCHY_PATH:=...}"), #8771 (omarchy-update-available, same form), #9980 (both files), and this one. The implementations are behaviourally identical; := and :- differ only in form here, and neither needs an export. Which combination lands is the maintainer's call and not something triage decides. Two things you may want to do meanwhile: this closes #8369 as well as #9953, and the sibling crash is tracked separately as #8769.

Also worth knowing, and shared by every one of those changes: on a dev-linked install, omarchy-dev-link writes the checkout to /etc/omarchy.conf and grants sudo a secure_path into it but no env_keep, so under sudo the default resolves to /usr/share/omarchy and the checkout is silently not pulled — against the contract at docs/update-process.md:138. That trades a crash for a silent skip rather than making root updates correct; bin/omarchy-restart-shell:9 still resolves an empty path under sudo and bin/omarchy-update-restart:51 swallows the failure. Reporting it for the maintainer, not asking you to widen this pull request.

@bjarneo

bjarneo commented Sep 21, 2026

Copy link
Copy Markdown
Member

Automated duplication check: this pull request looks similar to #8590, which covers the same OMARCHY_PATH default in update-dev. I keep that one open and close this one to consolidate review.

If you feel this is the wrong decision, please open the PR again with a note on the difference.

@bjarneo bjarneo closed this Sep 21, 2026
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.

sudo omarchy update aborts with "OMARCHY_PATH: unbound variable" in omarchy-update-dev

3 participants