Operating system version
macOs Ventura 13.5.2
System architecture
ARM64 (M1, M2, etc)
Herd Version
1.2.0 (Build: 14)
PHP Version
No response
Bug description
Hi all, I'm experiencing two minor issues when editing the $PATH variable line Herd injected line into my ~/.zshrc
Issue when removing the trailing slash from the Herd PHP binary folder
When I update the line Herd injected into my ~/.zshrc from:
# Herd injected PHP binary.
export PATH="/Users/brtdv/Library/Application Support/Herd/bin/":$PATH
to
# Herd injected PHP binary.
export PATH="/Users/brtdv/Library/Application Support/Herd/bin":$PATH
(note the removed trailing slash).
When I quit and re-launc Herd, Herd will re-inject an additional line at the end of the file with, causing the ~/.zshrc file to have two lines with the same folder injected into $PATH, causing my ~/.zshrc to contain two duplicate lines:
# Herd injected PHP binary.
export PATH="/Users/brtdv/Library/Application Support/Herd/bin":$PATH
# Herd injected PHP binary.
export PATH="/Users/brtdv/Library/Application Support/Herd/bin/":$PATH
Why would I want to remove this trailing slash? A meaningless thing but: when I output which php, the result is /Users/brtdv/Library/Application Support/Herd/bin//php (note the double slash). If you remove the trailing slash from the path that is injected into the $PATH, the php filepath will be output correctly, without double slash:
❯ which php
/Users/brtdv/Library/Application Support/Herd/bin/php
Herd being aggressive about the index of the PHP binary folder index in the $PATH variable
I'm still trying to use some of the homebrew PHP binaries in combination with Herd. For that reason, I tried to edit the $PATH manually so that Herd's PHP binary path is injected into the $PATH at the last index.
I tried editing
# Herd injected PHP binary.
export PATH="/Users/brtdv/Library/Application Support/Herd/bin/":$PATH
to
# Herd injected PHP binary.
export PATH=$PATH:"/Users/brtdv/Library/Application Support/Herd/bin/"
When I update my local setup like this, when I use brew link php, these binaries will get priority over Herds' php binaries. When i then run brew unlink php, I can then re-use Herds' PHP binaries.
However, next time I launch Herd, it will again reinject its PHP folder at the first index of the $PATH, causing the ~/.zshrc file to contain:
# Herd injected PHP binary.
export PATH=$PATH:"/Users/brtdv/Library/Application Support/Herd/bin/"
# Herd injected PHP binary.
export PATH="/Users/brtdv/Library/Application Support/Herd/bin/":$PATH
I understand that the way this is injected into the $PATH "on first run" is the best way for beginner and novice users and fits the best with Herd's "Zero dependencies. Zero headaches." mantra. This should not be changed! However, when I manually edit the $PATH to have Herd's php binaries folder at the last index, I feel Herd should respect that and not try to re-inject itself at index 0 of the $PATH's folders?
I think both issues are related and could be fixed by Herd treating the $PATH as an array of folders on boot and checking if the "~/Library/Application Support/Herd/bin" folder is present anywhere in the array of folders of $PATH? Right now Herd seems to check only if the folder is present at the first index of $PATH (or at the beginning of the "string" $PATH?)
Steps to reproduce
Issue 1
- Open
~/.zshrc
- Update the line containing
export PATH="/Users/brtdv/Library/Application Support/Herd/bin/":$PATH by removing the trailing slash, like so: export PATH="/Users/brtdv/Library/Application Support/Herd/bin":$PATH
- Restart the Herd macOS app
- Herd will reinject a line containing
export PATH="/Users/brtdv/Library/Application Support/Herd/bin/":$PATH and your ~/.zshrc $PATH variable will contain two references to the Herd PHP binary folder.
Issue 2
- Open
~/.zshrc
- Update the line containing
export PATH="/Users/brtdv/Library/Application Support/Herd/bin/":$PATH by placing the Herd PHP binary folder at the last index in $PATH, like so: export PATH=$PATH:"/Users/brtdv/Library/Application Support/Herd/bin/"
- Restart the Herd macOS app
- Herd will reinject a line containing
export PATH="/Users/brtdv/Library/Application Support/Herd/bin/":$PATH and your ~/.zshrc $PATH variable will contain two references to the Herd PHP binary folder.
Relevant log output
No response
Operating system version
macOs Ventura 13.5.2
System architecture
ARM64 (M1, M2, etc)
Herd Version
1.2.0 (Build: 14)
PHP Version
No response
Bug description
Hi all, I'm experiencing two minor issues when editing the
$PATHvariable line Herd injected line into my~/.zshrcIssue when removing the trailing slash from the Herd PHP binary folder
When I update the line Herd injected into my
~/.zshrcfrom:to
(note the removed trailing slash).
When I quit and re-launc Herd, Herd will re-inject an additional line at the end of the file with, causing the
~/.zshrcfile to have two lines with the same folder injected into$PATH, causing my~/.zshrcto contain two duplicate lines:Why would I want to remove this trailing slash? A meaningless thing but: when I output
which php, the result is/Users/brtdv/Library/Application Support/Herd/bin//php(note the double slash). If you remove the trailing slash from the path that is injected into the$PATH, thephpfilepath will be output correctly, without double slash:Herd being aggressive about the index of the PHP binary folder index in the
$PATHvariableI'm still trying to use some of the homebrew PHP binaries in combination with Herd. For that reason, I tried to edit the
$PATHmanually so that Herd's PHP binary path is injected into the$PATHat the last index.I tried editing
to
When I update my local setup like this, when I use
brew link php, these binaries will get priority over Herds' php binaries. When i then runbrew unlink php, I can then re-use Herds' PHP binaries.However, next time I launch Herd, it will again reinject its PHP folder at the first index of the
$PATH, causing the~/.zshrcfile to contain:I understand that the way this is injected into the
$PATH"on first run" is the best way for beginner and novice users and fits the best with Herd's "Zero dependencies. Zero headaches." mantra. This should not be changed! However, when I manually edit the$PATHto have Herd's php binaries folder at the last index, I feel Herd should respect that and not try to re-inject itself at index 0 of the$PATH's folders?I think both issues are related and could be fixed by Herd treating the
$PATHas an array of folders on boot and checking if the "~/Library/Application Support/Herd/bin" folder is present anywhere in the array of folders of$PATH? Right now Herd seems to check only if the folder is present at the first index of$PATH(or at the beginning of the "string" $PATH?)Steps to reproduce
Issue 1
~/.zshrcexport PATH="/Users/brtdv/Library/Application Support/Herd/bin/":$PATHby removing the trailing slash, like so:export PATH="/Users/brtdv/Library/Application Support/Herd/bin":$PATHexport PATH="/Users/brtdv/Library/Application Support/Herd/bin/":$PATHand your~/.zshrc$PATHvariable will contain two references to the Herd PHP binary folder.Issue 2
~/.zshrcexport PATH="/Users/brtdv/Library/Application Support/Herd/bin/":$PATHby placing the Herd PHP binary folder at the last index in$PATH, like so:export PATH=$PATH:"/Users/brtdv/Library/Application Support/Herd/bin/"export PATH="/Users/brtdv/Library/Application Support/Herd/bin/":$PATHand your~/.zshrc$PATHvariable will contain two references to the Herd PHP binary folder.Relevant log output
No response