162

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?

jww
  • 97,681
  • 90
  • 411
  • 885
mrdavidjcole
  • 1,862
  • 3
  • 15
  • 14
  • 1
    [@AristotlePagaltzis](http://stackoverflow.com/users/9410/aristotle-pagaltzis)'s [answer on SuperUser](http://superuser.com/a/580611/86416) gives the best solution in my opinion, allowing your system apps to continue using `/usr/bin`, while you ***selectively symlink*** the Homebrew executables that you want to use instead of the Apple-shipped versions, such as Git. –  Feb 27 '14 at 01:18
  • @mrdavidjcole: fengd did not answered that question? – fotinsky Jul 10 '15 at 10:07
  • Stack Overflow is a site for programming and development questions. This question appears to be off-topic because it is not about programming or development. See [What topics can I ask about here](http://stackoverflow.com/help/on-topic) in the Help Center. Perhaps [Super User](http://superuser.com/) or [Apple Stack Exchange](http://apple.stackexchange.com/) would be a better place to ask. Also see [Where do I post questions about Dev Ops?](http://meta.stackexchange.com/q/134306). – jww Apr 03 '16 at 17:25

5 Answers5

308

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

fengd
  • 7,551
  • 3
  • 41
  • 44
  • 9
    Reload the environment or start a new terminal after making this change. – mmell Feb 15 '13 at 17:48
  • 5
    Disagree with this - should use the below answer - time machine etc will not pick this change up I think as outside user folder. – Ian Warner Apr 20 '13 at 15:12
  • This is also the best solution I've found if your problem is that RVM and Homebrew both seem to be competing for same real estate in your .bash_profile file. – MCB Feb 22 '14 at 18:14
  • 1
    I would NOT edit /etc/paths; instead, use the .profile / .bash_profile methods described elsewhere (e.g., answer by @avelis below or for a more paranoid approach, see the first comment referencing AristotlePagaltzis answer on SuperUser. – rholmes May 16 '14 at 22:54
  • 1
    You may want to try using the nano terminal text editor instead of via. I found this to be easier to use. "sudo nano /etc/paths" instead of "sudo vi /etc/paths". – tbradley22 Jul 13 '14 at 05:32
  • Why edit /etc when you could just configure it to the local user account. I'm with the others who disagree that this is the best solution. –  Aug 11 '14 at 03:01
81

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/

avelis
  • 1,143
  • 1
  • 9
  • 18
  • 2
    @JanuszChudzynski For Jun1st's solution, it might be that you have to restart the command line session in order to see the change. – avelis Oct 29 '12 at 19:11
  • Recent versions of homebrew day: *Consider setting your PATH so that /usr/local/bin occurs before /usr/bin. Here is a one-liner: `echo export PATH="/usr/local/bin:$PATH" >> ~/.bash_profile`*. Which is basically what this answer suggests. – nacho4d Nov 02 '13 at 01:27
  • However I doubt it is the right way. See below: Before change:`/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin` change: `echo export PATH="/usr/local/bin:$PATH >> ~/.bash_profile` After change: `/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin` This means that if a command is not found in /usr/local/bin it might get searched twice before it is found in another path. I think it is better to change the `/etc/paths` file – nacho4d Nov 02 '13 at 01:32
  • $ echo 'export PATH="/usr/local/bin:$PATH"' >> ~/.bash_profile gives me $PATH"' >> ~/.bash_profile -bash: $: command not found – Mamba Jan 27 '15 at 16:50
  • @rpeg I am sure if you web search for tutorials there is an abundance of resources, but here is one I know of. http://www.linux.com/learn/tutorials/272346-bash-101-working-at-the-cli – avelis Mar 07 '15 at 01:25
23

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

iceturk22
  • 341
  • 3
  • 4
1

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

0

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

Community
  • 1
  • 1
mycargus
  • 2,538
  • 3
  • 23
  • 31