Repository navigation
Prepend the Omarchy bin dir in dev-link mode only - #7239
omarchybot wants to merge 1 commit into
Conversation
envs.lua put $OMARCHY_PATH/bin first on PATH for the whole graphical session unconditionally, while env-bootstrap deliberately does it only in dev-link mode. On a production install the two directories are not interchangeable: /usr/share/omarchy/bin holds symlinks for the omarchy package's binaries alone, so it shadowed a complete /usr/bin with an incomplete copy. Since bin/omarchy resolves subcommands by globbing its own directory, every omarchy-* command another package ships to /usr/bin lost its route inside the session while still working from a login shell -- omarchy debug, omarchy debug idle and omarchy upload log from omarchy-settings, omarchy nvim setup and omarchy nvim refresh from omarchy-nvim, and anything a future package adds the same way. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Adjusts how PATH is manipulated in Hyprland session env setup to avoid shadowing system binaries in production installs, while keeping dev-link behavior consistent with other bootstrap scripts.
Changes:
- Adds a production-vs-dev guard to only prepend
OMARCHY_PATH/binin non-production (dev-link) setups. - Normalizes
paths.omarchy_pathby trimming trailing slashes before comparisons. - Expands inline documentation explaining why prepending
/usr/share/omarchy/binis harmful in production.
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| -- Prepend only in dev-link mode, matching default/bash/env-bootstrap. On a | ||
| -- production install /usr/share/omarchy/bin holds symlinks for the `omarchy` | ||
| -- package's binaries alone, so putting it first shadows the complete /usr/bin | ||
| -- with an incomplete copy -- and the dispatcher scans its own directory, so | ||
| -- every omarchy-* command another package ships to /usr/bin (omarchy-debug, | ||
| -- omarchy-debug-idle, omarchy-upload-log from omarchy-settings; | ||
| -- omarchy-nvim-setup, omarchy-nvim-refresh from omarchy-nvim) loses its route | ||
| -- for the whole graphical session. | ||
| local omarchy_path = paths.omarchy_path:gsub("/+$", "") | ||
| if omarchy_path ~= "/usr/share/omarchy" then | ||
| local bin_dir = omarchy_path .. "/bin" | ||
| local kept = {} | ||
| for entry in (os.getenv("PATH") or "/usr/local/bin:/usr/bin"):gmatch("[^:]+") do | ||
| if entry ~= bin_dir then table.insert(kept, entry) end | ||
| end | ||
| table.insert(kept, 1, bin_dir) | ||
| hl.env("PATH", table.concat(kept, ":")) | ||
| end |
| local omarchy_path = paths.omarchy_path:gsub("/+$", "") | ||
| if omarchy_path ~= "/usr/share/omarchy" then | ||
| local bin_dir = omarchy_path .. "/bin" | ||
| local kept = {} | ||
| for entry in (os.getenv("PATH") or "/usr/local/bin:/usr/bin"):gmatch("[^:]+") do | ||
| if entry ~= bin_dir then table.insert(kept, entry) end |
|
This fixes the production case, but the dev-link branch keeps the half of the behaviour that clobbers user PATH order, and I think it's worth closing here rather than in a follow-up.
if [ "$OMARCHY_PATH" != /usr/share/omarchy ]; then # 1. dev-link only
case ":$PATH:" in
*":${OMARCHY_PATH%/}/bin:"*) ;; # 2. already present
*) PATH="${OMARCHY_PATH%/}/bin${PATH:+:$PATH}" ;;
esac
fiThis PR ports guard 1. Guard 2 is still missing, so inside dev-link mode the strip-and-prepend continues to move an entry that is already on Concretely, on a portable install ( Suggested addition, keeping the dedup and prepending only when absent: local bin_dir = omarchy_path .. "/bin"
local kept, seen_bin = {}, false
for entry in (os.getenv("PATH") or "/usr/local/bin:/usr/bin"):gmatch("[^:]+") do
if entry ~= bin_dir then
table.insert(kept, entry)
elseif not seen_bin then
seen_bin = true
table.insert(kept, entry)
end
end
if not seen_bin then
table.insert(kept, 1, bin_dir)
end
hl.env("PATH", table.concat(kept, ":"))
|
|
Reviewed at 037242e against Reproduced on a worker built from the Omarchy ISO (omarchy 4.0.4, set up as a production install with Why #13351 is preferable. It deletes the Second opinion: Codex Medium was asked to pick between the two fixes without being told which one this review favoured. It chose #13351 for the same reason. It also checked #13351's test, which fails against this branch and passes with #13351's change applied, and found no defect in that pull request. It flagged that this branch's Waiting on the maintainer to choose between the two. If #13351 lands, this one can be closed. #13351 does not reference #6977, so linking it there would close the issue on merge. |
|
Thank you for this, @omarchybot. #13351 fixes the same problem in a way the review judged better, so this is closed in favour of it. 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. |
default/hypr/envs.luaputs$OMARCHY_PATH/binfirst onPATHfor the whole graphical session unconditionally, anddefault/hypr/autostart.luaimports that into the systemd user manager, so every terminal in the session inherits it. On a production install that directory is/usr/share/omarchy/bin, a symlink farm holding only the binaries theomarchypackage itself ships — so it shadows a complete/usr/binwith an incomplete copy. Sincebin/omarchyresolves subcommands by globbing its own directory with noPATHfallback, everyomarchy-*command another package installs to/usr/binloses its route inside the session while still working from a login shell.default/bash/env-bootstrapalready guards the identical prepend with[ "$OMARCHY_PATH" != /usr/share/omarchy ], anddocs/file-layout.mdstates that as the intended policy.envs.luais the half that never got the guard. This adds it, and normalizes a trailing slash so a hand-edited path cannot slip past the comparison.The reported symptom is
omarchy debug, but the blast radius is wider than the five commands named in the issues: it is everyomarchy-*route shipped by a package other thanomarchy. Today that isomarchy-debug,omarchy-debug-idleandomarchy-upload-logfromomarchy-settings,omarchy-nvim-setupandomarchy-nvim-refreshfromomarchy-nvim, plus four fromomarchy-emacsand one each fromomarchy-fishandomarchy-zsh— eleven routes, growing with every optional package that follows the same pattern.Fixing it here rather than by adding mirror symlinks keeps the invariant in one place: the alternative is editing six PKGBUILDs to drop files into a directory another package owns, and requiring every future package to remember. Dev-link installs are unaffected —
omarchy-dev-linkwrites a canonicalized path that is not/usr/share/omarchy, so the prepend still fires there.Worth noting there is no test harness for
envs.lua;test/shell.d/dev-env-path-test.shcovers theenv-bootstrapside only and is untouched here.Fixes #6977