How to modify PATH for Homebrew?

RubyPathHomebrew

Ruby Problem Overview


Trying to install ruby 1.9.3, read that I need to install homebrew first. Ran brew doctor, and it's giving me a bunch of warnings. One of which is:

> Warning: /usr/bin occurs before /usr/local/bin This means that > system-provided programs will be used instead of those provided by > Homebrew. The following tools exist at both paths: > > easy_install > easy_install-2.6 > > Consider amending your PATH so that /usr/local/bin is ahead of > /usr/bin in your PATH.

How does one do what it's asking here?

Ruby Solutions


Solution 1 - Ruby

open your /etc/paths file, put /usr/local/bin on top of /usr/bin

$ sudo vi /etc/paths
/usr/local/bin
/usr/local/sbin
/usr/bin
/bin
/usr/sbin
/sbin

and Restart the terminal, @mmel

Solution 2 - Ruby

There are many ways to update your path. Jun1st answer works great. Another method is to augment your .bash_profile to have:

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

The line above places /usr/local/bin and /usr/local/sbin in front of your $PATH. Once you source your .bash_profile or start a new terminal you can verify your path by echo'ing it out.

$ echo $PATH
/usr/local/bin:/usr/local/sbin:/Users/<your account>/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin

Once satisfied with the result running $ brew doctor again should no longer produce your error.

This blog post helped me out in resolving issues I ran into. http://moncefbelyamani.com/how-to-install-xcode-homebrew-git-rvm-ruby-on-mac/

Solution 3 - Ruby

Just run the following line in your favorite terminal application:

echo export PATH="/usr/local/bin:$PATH" >> ~/.bash_profile

Restart your terminal and run

brew doctor

the issue should be resolved

Solution 4 - Ruby

open bash profile in textEdit

open -e .bash_profile

Edit file or paste in front of PATH export PATH=/usr/bin:/usr/sbin:/bin:/sbin:/usr/local/bin:/usr/local/sbin:~/bin

save & close the file

*To open .bash_profile directly open textEdit > file > recent

Solution 5 - Ruby

To avoid unnecessary duplication, I added the following to my ~/.bash_profile

case ":$PATH:" in
  *:/usr/local/bin:*) ;;     # do nothing if $PATH already contains /usr/local/bin
  *) PATH=/usr/local/bin:$PATH ;;  # in every other case, add it to the front
esac

Credit: https://superuser.com/a/580611

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionmrdavidjcoleView Question on Stackoverflow
Solution 1 - RubyfengdView Answer on Stackoverflow
Solution 2 - RubyavelisView Answer on Stackoverflow
Solution 3 - Rubyiceturk22View Answer on Stackoverflow
Solution 4 - RubySiddhant RautView Answer on Stackoverflow
Solution 5 - RubymycargusView Answer on Stackoverflow