Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

If I do echo $PATH I get the following:

/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/usr/local/share/npm/bin:/usr/local/share/python:/opt/X11/bin:/Users/kh/.rvm/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/opt/X11/bin

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

~/.bash_profile
~/.bashrc
~/.profile

Any suggestions.

share|improve this question

4 Answers 4

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

/opt/X11/bin
/usr/bin
/usr/local/bin
/usr/sbin

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

share|improve this answer

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
share|improve this answer

According the the ZSH manual page:

STARTUP/SHUTDOWN FILES

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:

/etc/zshenv
/etc/zshrc
/etc/zlogin

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`
fi

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

/etc/paths
/etc/paths.d/*
share|improve this answer
    
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 '13 at 18:50

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

PATH=$PATH:/additonally_location

So I think that PATH isn't duplicated.

share|improve this answer
    
It is being duplicated though and I want to try and figure out where –  showFocus Jun 9 '13 at 18:25
    
zsh search for a few files in you home, verify if one is duplicating your path: ~/.zshenv, ~/.zprofile, ~/.zlogin –  Victor Aurélio Jun 9 '13 at 18:29
    
Thanks. But i've just done that all files are empty or dont exist at all –  showFocus Jun 9 '13 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 '13 at 19:02

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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