echo $PATH
gives me
/Library/Frameworks/Python.framework/Versions/3.4/bin:/Applications/Sublime Text 2.app/Contents/SharedSupport/bin:/Users/pathreskoo/anaconda/bin:/Library/Frameworks/Python.framework/Versions/2.7/bin:/opt/local/bin:/opt/local/sbin:/Library/Frameworks/Python.framework/Versions/2.7/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/usr/local/git/bin
but when I want to change the order of /usr/local/bin
to the front of /Library/Frameworks/Python.framework/Versions/3.4/bin
, I type
sudo emacs /etc/paths
I only get
/usr/local/bin:
/usr/bin:
/bin:
/usr/sbin:
/sbin:
How can I insert /usr/local/bin
in front of my PATH
?
I've seen numerous articles (see 1 2 3) addressing if order matters with regards to entries in the PATH environment variable and it is clear that the answer is a resounding yes.
You can set your PATH
in the file .bash_profile
, which is in your home directory.
More specifically, you can simply add the following line to the end of that file
export PATH=/usr/local/bin:$PATH
This results in /usr/local/bin
being prepended to the existing PATH
. In other words, the folder /usr/local/bin
is inserted in front of your PATH
, and so it would have the highest priority. You can also append a folder to your path by doing
export PATH=$PATH:/usr/local/bin
In general, you can set the order of the folders or files that you export in a similar way as the following:
export PATH=/usr/local/bin:/Applications/Sublime Text 2.app/Contents/SharedSupport/bin:/Users/pathreskoo/anaconda/bin:/Library/Frameworks/Python.framework/Versions/2.7/bin:/opt/local/bin:/opt/local/sbin:/Library/Frameworks/Python.framework/Versions/2.7/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/usr/local/git/bin
Note: this is not the only place you can set the PATH
, but it is a common one.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With