If I do echo $PATH I get the following:


This is in my ~/.zshrc file:

export PATH=/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/usr/local/share/npm/bin:/usr/local/share/python:/opt/X11/bin:$HOME/.rvm/bin:$PATH

I've had to manually add /usr/local/etc... at the front of this file because homebrew was complaining.

I've searched for all possibles files (I know of) to find where $PATH is being built from. But to no avail. These are


Any suggestions.

  • Was this question ever given an accepted answer or otherwise solved? (It is showing as being 8 years old...)
    – C. M.
    Apr 11 at 18:37

4 Answers 4


I don't know which other file is setting your $PATH but the duplicated entries are


All of these are set in your ~/.zshrc so all you need to do is not set them there. In any case, these should all be in the default $PATH and there is no need to add them. Most systems come with a default $PATH that will include these directories, additions made in users' ~/.zshrc files should only add non-standard directories.

Change your $PATH declaration to

export PATH=/usr/local/sbin:/usr/local/share/npm/bin:/usr/local/share/python:$HOME/.rvm/bin:$PATH


Default paths are defined in /etc/paths on OSX. As a sub-process inherits environment variables and you explicitly set /usr/bin/ in your $PATH you have duplicate entries.

To remove the duplicate entries you can use:

typeset -U PATH

According the the ZSH manual page:


Commands are first read from /etc/zshenv; this cannot be overridden. Subsequent behaviour is modified by the RCS and GLOBAL_RCS options; the former affects all startup files, while the second only affects global startup files (those shown here with an path starting with a /). If one of the options is unset at any point, any subsequent startup file(s) of the corresponding type will not be read. It is also possible for a file in $ZDOTDIR to re-enable GLOBAL_RCS. Both RCS and GLOBAL_RCS are set by default.

Commands are then read from $ZDOTDIR/.zshenv. If the shell is a login shell, commands are read from /etc/zprofile and then $ZDOTDIR/.zprofile. Then, if the shell is interactive, commands are read from /etc/zshrc and then $ZDOTDIR/.zshrc. Finally, if the shell is a login shell, /etc/zlogin and $ZDOTDIR/.zlogin are read.

Thus, you may want to check:


and any files they happen to source. Since you are OS X, it is likely you'll find something like:

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

which, according to the path_helper man page, will also look in:

  • Nothing in:/etc/zshenv /etc/zshrc /etc/zlogin and can't change order in /etc/paths as some command may rely on using system default version in /usr/bin rather than /usr/local/bin
    – showFocus
    Jun 9, 2013 at 18:50

You can set additional paths to PATH using the following syntax:


So I think that PATH isn't duplicated.

  • It is being duplicated though and I want to try and figure out where
    – showFocus
    Jun 9, 2013 at 18:25
  • zsh search for a few files in you home, verify if one is duplicating your path: ~/.zshenv, ~/.zprofile, ~/.zlogin Jun 9, 2013 at 18:29
  • Thanks. But i've just done that all files are empty or dont exist at all
    – showFocus
    Jun 9, 2013 at 18:36
  • @showFocus in that case please update your question to list the zsh files you have searched through, .bashrc and .bash_profile are irrelevant.
    – terdon
    Jun 9, 2013 at 19:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.