Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

brew doctor says "Error: /usr/bin occurs before /usr/local/bin" how to fix?

Adams-MacBook-Pro% brew doctor                                   Error: /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:      clusterdb     createdb     createlang     createuser     dropdb     droplang     dropuser     ecpg     git     git-cvsserver     git-receive-pack     git-shell     git-upload-archive     git-upload-pack     gitk     pg_config     pg_dump     pg_dumpall     pg_restore     pg_upgrade     psql     reindexdb     vacuumdb  Consider amending your PATH so that /usr/local/bin is ahead of /usr/bin in your PATH. 

Here is my path:

Adams-MacBook-Pro% echo $PATH                                   /usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin 

I thought it was dangerous to move things to the front? How do I solve this problem? Also, I'm not even sure where to find where /user/bin is declared in the path.

Thanks

like image 956
AdamT Avatar asked Jul 04 '12 22:07

AdamT


2 Answers

$PATH is just a variable containing a string. To put something in front:

% PATH=/usr/local/bin:$PATH % echo $PATH /usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin 

This is not dangerous, since it only applies to the current shell you have open (it will not affect the path for your system or other shells).

To change the path automatically for all shells you open, put it in ~/.profile. You can create this file if it doesn't already exist.

In ~/.profile:

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

export makes the variable available to any child processes of the shell.

like image 181
Dean Avatar answered Nov 09 '22 17:11

Dean


I found another way to solve this.

sudo vim /etc/paths 

and add /usr/local/bin and /usr/local/sbin like this

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

open a new terminal tab, and then you will see

~ $ env|grep PATH PATH=/usr/local/bin:/usr/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin 
like image 23
Lelouchcr Avatar answered Nov 09 '22 17:11

Lelouchcr