shell path_finder


Arumoy Shome


June 1, 2020

How $PATH is constructed on OSX.

The /etc/profile file is executed each time a login shell is started. If we investigate this file, we see the following:

# System-wide .profile for sh(1)

if [ -x /usr/libexec/path_helper ]; then
    eval `/usr/libexec/path_helper -s`

if [ "${BASH-no}" != "no" ]; then
    [ -r /etc/bashrc ] && . /etc/bashrc

So each time a login shell is started, path_helper is run. In short, it takes the paths listed in /etc/paths & etc/paths.d/, appends the existing PATH and clears the duplicates1.

  • 1 This Stack overflow post explains how path_helper operates in mode details.

  • Tmux2 always runs as a login shell. Thus a common problem within tmux is duplicate entries =PATH= (in a different order than what we specify in our shell config files).

  • 2

  • Thus, it’s okay to append to =PATH= in the shell config files, but prepending causes unwanted side-effects. We could edit =etc/paths= manually, but this requires sudo and is generally not advised.

    Back to top