I'm using Homebrew on Mac OS X 10.8.3. Homebrew wants the /usr/local/bin
directory earlier in the PATH than /usr/bin
, otherwise system-provided programs will be used instead of Homebrew managed replacements.
I'm using zsh, and in my .zshenv
I reset the PATH, and then use path_helper to initialize it, like so:
if [ -x /usr/libexec/path_helper ]; then
PATH=''
eval `/usr/libexec/path_helper -s`
fi
Immediately following this, also in .zshenv
, I prepend /usr/local/bin
to the PATH.
export PATH="/usr/local/bin:$PATH"
There are various other additions to $PATH. RVM, /usr/local/sbin
and my personal bin
directory:
export PATH=$HOME/.rvm/bin :$PATH
...
export PATH=$PATH:/usr/local/sbin:$HOME/bin
Finally, I use typeset -u
to remove any duplicates (although where they are coming from is a mystery to me) from the PATH.
typeset -U PATH
After all of this here is what my PATH looks like:
/Users/mark/.rvm/gems/ruby-1.9.3-p374/bin
/Users/mark/.rvm/gems/ruby-1.9.3-p374@global/bin
/Users/mark/.rvm/rubies/ruby-1.9.3-p374/bin
/Users/mark/.rvm/bin
/usr/bin
/bin
/usr/sbin
/sbin
/usr/local/bin
/usr/local/sbin
/Users/mark/bin
I know that /etc/paths
sets these paths:
/usr/bin
/bin
/usr/sbin
/sbin
/usr/local/bin
so I edited that file and removed the /usr/local/bin' option so that the only place it is being set is in
.zshenv`.
All of this is contained in my dotfile repository on GitHub (https://github.com/zan5hin/dotfiles), and is being used on two laptops. On the first laptop the path is correct, with /usr/local/bin
immediately following the RVM entries. On the second laptop it appears as I detailed above.
I am at a loss to explain why the path is incorrect on the second machine when the zsh configuration is an identical copy.
Can anyone suggest why the path would be out of order?
Thanks.