I need to create a new path in OS X Mavericks.

To do so, I edited .bash_profile:

export LC_ALL="en_US.UTF-8"
export PGHOST=localhost

export PATH=$PATH:/usr/local/heroku/bin
export PATH=$PATH:/Applications/Postgres93.app/Contents/MacOS/bin

But it doesn't work. When I type echo $PATH, the result is:


This is the content of my .bashrc file:

PATH=$PATH:$HOME/.rvm/bin # Add RVM to PATH for scripting
PATH=$PATH:/usr/local/rvm/bin # Add RVM to PATH for scripting

I don't have (or find) a .profile file.

What am I doing wrong?


After editing the login file you need to either run the source command on the login file or create a new terminal session before the updated environment variables will be available.

For Example:

source .bash_profile

I prefer to use this method of adding to the path. That way, if the file is executed multiple times, $PATH doesn't add redundant paths.

# (do not remove this comment)
echo $PATH | grep -q -s "${HOME}/bin"
if [ $? -eq 1 ] ; then
    export PATH
  • I restarted the terminal one thousand time but it didn't work. Typing source .bash_profile instead refreshed the paths... Crazy... I Google a bit and it says that restarting the terminal doesn't reload .bashrc but is supposed to reload .bash_profile. Can I do anything to reload bash_profile automatically every time I restart terminal? – ndemoreau Oct 30 '13 at 5:33
  • 3
    I think the problem was due to the fact that I use zsh. I added source .bash_profile in the .zshrc file and it seems to refresh correctly now. Thanks for your help! – ndemoreau Oct 30 '13 at 5:42
  • what exactly did you add, and how? did you just insert ".bash_profile" somewhere in the file? – Dumoko Jan 24 '14 at 9:37
  • 2
    .bash_profile only applies to the bash shell. If you're using zsh, you need to make PATH changes to zsh-related files, like .zshrc, .zprofile, and .zlogin. Your Mac comes with several shells, including bash, zsh, and a few others. Each shell uses its own set of configuration files, and you can have two different shells open at the same time in different tabs in Terminal or iTerm. Instead of sourcing .bash_profile in your .zshrc, you should set the PATH in your .zshrc to keep the shells independent of each other. – monfresh Jan 30 '14 at 6:47

I managed to add a path on Mavericks by doing the following:

sudo vi /etc/paths

This opens the file called paths which includes all the local paths etc. In the end of this file I added the path I wanted using the vi editor as shown in the command above. I simply added a line such as /Applications/blabla/my_bin.

It will ask your password and after that it is done. It worked for me, hopefully does the same for you.


Add this to your .zshrc file:

if [ -f ~/.bash_profile ]; then . ~/.bash_profile; fi

This will load up your .bash_profile while zsh is loading since it doesn't load it by default.


Aside from the fact you can simply create a .profile file, adding stuff to the path, since Snow Leopard or Lion (most likely SL) is done by adding stuff to paths.d.

ls /etc/path*

40-XQuartz  MacGPG2     TeX         julia

i.e. go to /etc/paths.d/

touch a file called whatever_program_I_want_to_add_to_the_path , then edit it to have the path to the program:

cat /etc/paths.d/julia
cat /etc/paths.d/TeX

Close the terminal and restart it.

  • paths.d is for system-wide settings. It does not make direct setting of PATH obsolete, or impossible. – alexis Oct 29 '13 at 21:28
  • Can I use this to set the path to a directory? Just to make sure I understand correctly: I would then create a file called "postgres" and add this line into the file: /Applications/Postgres93.app/Contents/MacOS/bin ? – ndemoreau Oct 30 '13 at 5:27
  • yes, that's how it's now done in the recent versions of OSX – user1256923 Nov 1 '13 at 9:48

If you're trying to set paths/variables/completions/etc using process substitution on Mavericks, like this:

. <(npm completion)

That won't work: https://lists.gnu.org/archive/html/bug-bash/2006-01/msg00018.html Bash refuses to source from /dev/fds.

Basically, Mavericks's bash is far too old. Either install and configure your account to use a newer bash, or rewrite your script to use tempfiles or named processes. Here's an ugly example of a rewrite: dotfiles commit

(added for other google searchers who stumble across this page)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .