$PATH set in .zshenv gets overwritten by /etc/profile
Thanks to the mention of /etc/profile
in !6563 (merged) I was able to identify cause of .zshenv
not appending my paths by the login shell
Apparently Alpine's default /etc/profile sets PATH instead of appending to it.
I did not have such issue on Arch Linux since their /etc/profile looks like this:
# Append "$1" to $PATH when not already in.
# This function API is accessible to scripts in /etc/profile.d
append_path () {
case ":$PATH:" in
*:"$1":*)
;;
*)
PATH="${PATH:+$PATH:}$1"
esac
}
# Append our default paths
append_path '/usr/local/sbin'
append_path '/usr/local/bin'
append_path '/usr/bin'
# Force PATH to be environment
export PATH
# Load profiles from /etc/profile.d
if test -d /etc/profile.d/; then
for profile in /etc/profile.d/*.sh; do
test -r "$profile" && . "$profile"
done
unset profile
fi
# Unload our profile API functions
unset -f append_path
What makes Arch Linux's approach more convenient is that append_path function is exposed to all files in /etc/profile.d/
. It also gets utilized by certain packages on Arch Linux (such as java's bin being appended to path)