I literally just had a battle with this today.
On OS X Yosemite PATH is built up in a rather roundabout way.
I believe that, as cremefraiche says, ZSH has a built-in
$PATH that it uses if nothing else is set, but that's not where yours is coming from. First of all there is a file,
/etc/paths, that contains a list of directories. There is also a directory,
/etc/path.d that contains more files that contain directories. The program
/usr/libexec/path_helper takes these lists of directories, merges them with the existing
$PATH variable (if there is one), removes any duplicates, and outputs the result, with the
/etc/paths directories listed first.
You can try running it yourself, it doesn't do any harm. Here's the output from mine:
PATH="/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/usr/local/MacGPG2/bin:/Users/alan/.local/bin:/Users/alan/src/go/bin"; export PATH;
On it's own, this doesn't do anything, but it's called from, on my machine,
if [ -x /usr/libexec/path_helper ]; then
eval `/usr/libexec/path_helper -s`
This might vary on your machine, as it seems Apple have moved this code around a bit in different versions of OS X.
Here's the list of all the files that ZSH reads in OS X, in the order they are evaluated:
Some of these files aren't evaluated in certain circumstances, like when run as non-interactive shell scripts, but I'm not going to discuss that here. It's in the ZSH man page if you're interested.
$ man zsh
It's worth noting that
/etc/zprofile is run after
~/.zshenv, so if you follow the ZSH guidelines and set your
$PATH in .zshenv, it's probably going to be clobbered by
path_helper. If you're running into this problem it might be worth renaming
/etc/zshenv so the system
$PATH will be set as early as possible.