MacOSX has a truly global path setting that precedes any other setting like ~/.bash_profile.
The file /private/etc/paths is a list of pathnames. The order from top to bottom defines the resulting order in the $PATH variable.
After loading /private/etc/paths there is a directory /private/etc/paths.d/ with files in the same style. Those are appended to the $PATH variable.
The default content of /private/etc/paths looks like this:
/usr/bin
/bin
/usr/sbin
/sbin
/usr/local/binThe resulting $PATH variable looks like this:
$ echo "$PATH"
# => "/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin"When using homebrew in its standard way, all your packages end up in /usr/local.
This is a problem if you want to install software via homebrew that should replace system default installations.
Git is a good example.
The system default $ /usr/bin/git --version outputs git version 1.7.4.4.
Your homebrew installed git (at the time of writing) $ /usr/local/bin/git --version outputs git version 1.7.8.3.
But without changing the default path combination, you end up using system Git instead of homebrew Git.
There is various workarounds and fixes for this problem.
For example one could tackle this problem for a specific application. TextMate for example allows you to set TM_GIT to a git executable of your choice. But why bothering with application specific settings, when you can fix the problem at its root.
Here are the contents of my corrected /private/etc/paths. I've moved /usr/local/bin on top.
/usr/local/bin
/usr/bin
/bin
/usr/sbin
/sbin
The following one-liner is suitable to be pasted directly into the Terminal:
curl -s https://gist.github.com/nunogt/0c7ed28b4cd0f79ed600/raw/24b08a17e2603e5c8e762cb211c060dcb5a1805b/homebrew-osx-paths.sh | sudo /bin/bash