fix(zsh): set PATH in .zshenv so early .zshrc consumers resolve - #8
Conversation
This stack of pull requests is managed by Graphite. Learn more about stacking. |
There was a problem hiding this comment.
Pull request overview
Moves essential PATH setup earlier in Zsh startup so commands used during early .zshrc execution (and non-interactive shells) can resolve correctly, and removes an early dependency on Homebrew coreutils.
Changes:
- Move Homebrew + user bin PATH entries from
rc.d/01-environment.zshinto.zshenvso they are available before.zshrcplugin initialization and in non-interactive shells. - Replace banner randomness that depended on
gshufwith zsh’s built-in$RANDOM. - Add an “opencode” PATH entry to the managed
dot_zshrcto avoid it being reverted bychezmoi apply.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
dot_zshenv |
Prepends Homebrew and user bin directories early for all zsh invocations. |
dot_config/zsh/rc.d/01-environment.zsh |
Removes PATH manipulation now handled by .zshenv. |
dot_config/zsh/rc.d/00-banner.zsh |
Avoids early dependency on coreutils by using $RANDOM. |
dot_config/zsh/dot_zshrc |
Adds an opencode PATH entry (currently hardcoded). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| # Homebrew and $HOME/bin. Also set here rather than in rc.d/01-environment.zsh: | ||
| # .zshrc's `znap eval atuin '...'` runs before rc.d is sourced, so atuin (and | ||
| # anything else Homebrew-installed used earlier in .zshrc) was not yet on PATH | ||
| # at that point. Order below matches the old rc.d/01-environment.zsh so the | ||
| # final PATH priority is unchanged. |
374b7b0 to
0a6a025
Compare
main already moved ~/.local/bin and Homebrew into .zshenv, for the reason given there: rc.d is sourced at the end of .zshrc, so entries added there are invisible to non-interactive shells and to the earlier parts of .zshrc. Three entries never made the move. /opt/homebrew/sbin was dropped entirely rather than relocated, so its contents (addgnupghome, applygnupgdefaults) have been off PATH since. Added next to bin on both OSes, bin first, matching the order `brew shellenv` emits. $HOME/bin was left behind in rc.d and still had the original problem: ~/bin holds hermit, which is exactly the sort of thing a script or editor subprocess expects to resolve, and neither could see it. Moving it to .zshenv puts it behind mise rather than in front. That changes nothing today, because mise manages no tool of the same name. The opencode PATH line was never in the source at all. Its installer appended it to the deployed ~/.config/zsh/.zshrc, so it existed only as drift and the next `chezmoi apply` would have reverted it and taken opencode off PATH. The (N-/) note moved to .zshenv along with the entries it describes, and the rc.d header now says where paths live and why, so the next addition does not land back in the wrong file. Verified by rendering the template and sourcing it in an `env -i` shell: hermit, opencode and addgnupghome all resolve, and Homebrew's bin precedes sbin.
|
Reworked onto the current Most of the original commit is already upstream and done better.
The Verified by rendering the template and sourcing it in an |
0a6a025 to
fc7bdea
Compare

Homebrew, $HOME/bin and sbin were added in rc.d/01-environment.zsh,
sourced at .zshrc:124. But .zshrc runs
znap eval atuinat line 96 andsources rc.d/00-banner.zsh (which sorts before 01-) earlier still, so both
ran before PATH was ready and printed 'command not found'. Move those PATH
entries to .zshenv, keeping the same order so final priority is unchanged.
For the same reason the banner no longer shells out to gshuf (a coreutils
binary that may not be on PATH yet); it uses zsh's built-in $RANDOM instead.
Also folds in the opencode PATH line the installer had appended to the
deployed ~/.config/zsh/.zshrc, so chezmoi apply no longer reverts it.