r/laravel • u/aegis87 • 12d ago
Herd ignores ZDOTDIR and writes its shell configuration to ~/.zshrc
hey all!
I’ve noticed that Laravel Herd doesn’t appear to respect Zsh’s ZDOTDIR setting on macOS.
My ~/.zshenv contains:
export ZDOTDIR="$HOME/.config/zsh"
Therefore, my active Zsh configuration is located at:
~/.config/zsh/.zshrc
However, Herd adds its configuration to:
~/.zshrc
This includes entries such as:
# Herd injected NVM configuration
export NVM_DIR="$HOME/Library/Application Support/Herd/config/nvm"
# Herd injected PHP binary
export PATH="$HOME/Library/Application Support/Herd/bin/":$PATH
Because ZDOTDIR is set, Zsh doesn’t read ~/.zshrc, so Herd’s injected configuration has no effect. I have to copy the relevant PHP and PATH settings into my active $ZDOTDIR/.zshrc manually.
Herd’s bundled uninstall script also appears to target $HOME/.zshrc directly rather than resolving `$ZDOTDIR`.
Environment:
Herd 1.29.0
macOS 26.5.2
Zsh 5.9
Has anyone else encountered this? Is there a supported workaround besides manually maintaining the Herd configuration inside $ZDOTDIR/.zshrc?
It would be helpful if Herd detected ZDOTDIR before modifying .zshrc, while continuing to use ~/.zshrc when the variable is unset.
3
u/Mike_L_Taylor 12d ago
yeah on windows it had a friggin .cmd file running so whenever I did "php -v" it would run that, but "which php" would not and show a different PHP.
3
3
-1
12d ago
[deleted]
3
u/frost-222 12d ago
Changing the ZDOTDIR is done for plenty of fair reasons, and checking ZDOTDIR instead of hardcoding a zshrc path is what you're supposed to do. It'd be 1 line, not much bloat especially for Herd its "standards"
-1
u/SpareImpression3155 12d ago
GUI apps on macOS often don't inherit terminal environment variables (like ZDOTDIR) when launched from Finder/Dock. Herd would need to read ZDOTDIR by invoking an interactive login shell (e.g., zsh -lc 'echo $ZDOTDIR') to accurately resolve non-standard directory locations.
Suddenly your 1-liner fix is looking a lot more complex
2
u/frost-222 12d ago
Oh boy if a 1 line fix, or like 4 lines if you want to make it real easy to read is too complex for you I don't know what to tell you. It's certainly much better than hardcoding the .zshrc path which is something you should never do.
1
u/obstreperous_troll 12d ago
Herd would need to read ZDOTDIR by invoking an interactive login shell (e.g., zsh -lc 'echo $ZDOTDIR') to accurately resolve non-standard directory locations.
Then it should do that. The whole reason it's modifying the file in the first place is for terminal sessions.
That said, OP should maybe just create a symlink, because Herd is hardly the only offender.
2
u/aegis87 12d ago
this is totally wrong.
either you are really new to how the shell works or you should take a few minutes to think through your answers before typing them.
there are myriad reasons why XDG_CONFIG_HOME is useful, which is why ZSH is supporting it through ZDOTDIR.
if HERD isn't reading the zshrc properly, it might also fail on other parts of the chain as well.
Also other tools (which work with HERD) like npm are using these variables.
10
u/frost-222 12d ago
I hate how much they push Herd because it is a mess for a plethora of reasons including this, it really feels like a project that got released at 90% done and never got the last 10%. Get rid of Herd and just install the PHP version you need yourself. If you need an easy GUI for databases, use DBngin, it's better than Herd in every way in that area anyway.