Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting PATH on OS X 10.9 is not working

I have searched all posts regarding PATH issues on Mac, but have not found an answer to mine.

I want to get /usr/local/bin to be searched first. I used homebrews example but it did not work. I created the .bash_profile file and put in:

export PATH="/usr/local/bin:$PATH"

As homebrew says except this seems to remove the standard commands for me with ls, cd, etc not working. I want it to search this folder first. I found the /etc/paths file and saw that it /usr/local/bin is located last.

Following instructions found here not to mess with the path file, I removed the change I made to .bash_profile and was able to get it to work (brew doctor is successful) with putting in

export PATH=/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin

I have tested this on two different Macs, and neither accepts appending the $PATH. Doing some research it seems that there is a path_helper file which calls stuff which may have changed in OS x 10.9. Is there a way to get the appending to work? I have tried it with the quotes and without and neither works. And each time I have restarted terminal or tried the source ~/.bash_profile command

I would prefer to not rewrite the whole path in .bash_profile, or at least know why appending it is not working.

like image 995
user2453911 Avatar asked Dec 17 '25 11:12

user2453911


2 Answers

After some investigation it turns out that the problem may have been how file ~/.bash_profile was created - it may not have been a plain-text file (due to use of TextEdit).

Recreating it with a plain-text editor (Sublime Text) solved the problem.


Follow-up question by the OP:

As for prepending /usr/local/bin without having it appear twice in $PATH:

export PATH="/usr/local/bin:${PATH/:\/usr\/local\/bin/}"

${PATH/:\/usr\/local\/bin/}, using bash's parameter/variable expansion, removes /usr/local/bin, if present, from the existing $PATH.

like image 197
mklement0 Avatar answered Dec 19 '25 06:12

mklement0


edit the /etc/paths to look like

/usr/local/bin
/usr/local/sbin
/usr/bin
/bin
/usr/sbin
/sbin

if it didn't work then add export PATH="/usr/local/bin:$PATH" to the .bash_profile and it should work...

like image 39
a14m Avatar answered Dec 19 '25 06:12

a14m



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!