Starting with Leopard, the program /usr/libexec/path_helper was introduced to help manage the $PATH environment variable.
It is started by the /etc/profile file:
1 2 3 | |
When path_helper is called, it searches various files, looking for new paths to add…
- it first reads from the file
/etc/paths - then reads files under the folder
/etc/paths.d/ - and finally, oddly enough, the initial value of $PATH (prior to calling path_helper) is appended
Under the hood:
- path_helper only appends unique paths, so duplicates are avoided
- files from
etc/paths.dare read in alphabetical order by filename - the default value for $PATH (prior to calling path_helper) is
/usr/bin:/bin:/usr/sbin:/sbin - the default contents of file
etc/pathsis
1 2 3 4 5 | |
How do I add more Paths ?
To add custom paths, you should create a plaintext file containing new paths (one per line) and place the file under the folder /etc/paths.d. Remember to end file with a newline!
Or from the terminal you can:
1
| |
How do I make Homebrew happy ?
brew doctor commonly complains that /usr/bin is in your PATH before Homebrew's bin.
To fix this, move /usr/local/bin to the top of list in /etc/paths.
NOTE: The above changes are system-wide and will affect all users. If you only want to modify $PATH for a specific user, edit
~/.bash_profile, ~/.bash_login, or ~/.profile instead.