Reputation: 6485
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
Upvotes: 39
Views: 35643
Reputation: 1
I'm using linuxbrew with wsl and got a similar error warning.
### .zshrc ###
export PATH="$PATH:/home/linuxbrew/.linuxbrew/bin"
export PATH="$PATH:/home/linuxbrew/.linuxbrew/sbin"
The problem was that $PATH was written at the beginning. The description has been changed as follows.
### .zshrc ###
export PATH="/home/linuxbrew/.linuxbrew/bin:$PATH"
export PATH="/home/linuxbrew/.linuxbrew/sbin:$PATH"
After running source ~/.zshrc, I ran brew doctor and the error disappeared.
Upvotes: 0
Reputation: 500
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
Upvotes: 23
Reputation: 1306
You need to restart your Terminal after any change with $PATH.
Upvotes: 1
Reputation: 31
Maybe OP's using zsh.
The way to solve it is edit the ~/.zshrc everytime you open iterm will load this file.
Change the words about PATH.
Upvotes: 3
Reputation: 9128
$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.
Upvotes: 50
Reputation: 351
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
Upvotes: 11
Reputation: 2687
If you really want to make it permanent and default, edit the file /etc/paths (using sudo) and move /usr/local/bin to the top of the list.
In my own .bash_profile I use a script called "pathadd" that prevents my PATH from getting unwieldy and full of duplicates when shells are forked. So I took the /etc/paths action specifically to avoid having duplicate directories in the PATH by adding /usr/local/bin to the front again and again.
Upvotes: 2
Reputation: 1618
I just created a .bashrc file and added
homebrew=/usr/local/bin:/usr/local/sbin
export PATH=$homebrew:$PATH
That seemed to have done the trick!
Upvotes: 5