23

I'm trying to install brew but get the following warning:

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:

2to3
2to3-2.7
idle
idle2.7
pydoc
pydoc2.7
python
python-config
python2.7
python2.7-config
pythonw
pythonw2.7
smtpd.py
smtpd2.7.py

Consider amending your PATH so that /usr/local/bin
is ahead of /usr/bin in your PATH.

I have no idea how to amend the path. I've explored several files from this stack overflow post (http://stackoverflow.com/questions/8886114/using-brew-with-ruby-1-9-2), but can't find a relevan path to edit. The only file that I do have that exists is my /etc/profile file which currently looks like:

# Setting PATH for Python 2.7
# The orginal version is saved in .bash_profile.pysave
    PATH="/Library/Frameworks/Python.framework/Versions/2.7/local/bin:${PATH}"
export PATH

I wanted to just uninstall python then reinstall it through homebrew, but am a little nervous about breaking too many things at once.

Is there an easy way to amend the path? Should I create a .bash_profile file? Thank you for any help in advance.

28

Yes, create a .bash_profile file in your home directory containing

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

and then do one of the following to make the change active

  • execute . ~/.bash_profile
  • execute PATH="/usr/local/bin:$PATH" in the current shell
  • restart Terminal
  • 2
    @threenovation if the answer above is correct, can I suggest you mark it as answer (click the tick next to the answer) – Stu Wilson Apr 23 '12 at 10:37
  • I wonder if this should be exported? Child processes should have this new path also. Also: When I set up brew, it did not alert me that /usr/bin came before /usr/local/bin. – Steven Lu May 3 '12 at 15:00
  • @StevenLu, it's already exported by the time you get to .bash_profile. It wouldn't hurt to explicitly export it again, but not necessary. – glenn jackman May 3 '12 at 15:20
  • Thanks for this. Worked "Your system is raring to brew." – Vezu May 29 '12 at 18:46
  • I seem to be getting duplicate entries in $PATH. – flow2k Sep 30 '18 at 21:22
10

You need to amend /etc/paths so that /usr/local/bin is listed before /usr/bin. You'll need to sudo your editor in order to do that.

One of the ways to open editor is

 sudo open -t /etc/paths
  • My PATH was configured correctly in my .bash_profile, but not in /etc/paths. This worked beautifully. – Nick Tomlin Jul 17 '13 at 17:03
  • 6
    Do NOT use this method for setting your path -- there is risk that non-terminal applications will pick up the "brewed" components and fail. Using "sudo" should also be a red flag unless you truly understand what you're doing (especially with a user-level development system like Mac Homebrew). Editing your .bash_profile and restarting terminal should be sufficient. – rholmes May 18 '14 at 21:04
  • @rholmes So changes to .bash_profile affects interactive user shells only and not other applications? – flow2k Sep 30 '18 at 21:21
  • 1
    @flow2k .bash_profile will affect interactive user shells. Any exported variables will be seen by applications launched from the shell command line (for example, launching a "regular" Mac app, or a command line command). Some more details can be found here, but they're making a finer distinction than what you asked: scriptingosx.com/2017/04/about-bash_profile-and-bashrc-on-macos The answer by glenn jackman is the one to use. – rholmes Oct 1 '18 at 22:12
  • 1
    @flow2k yes, you’ve stated that correctly. – rholmes Oct 2 '18 at 1:43

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.