bash brew doctor 说“错误:/usr/bin 发生在/usr/local/bin 之前”如何解决?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11335908/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
brew doctor says "Error: /usr/bin occurs before /usr/local/bin" how to fix?
提问by AdamT
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.
我认为将东西移到前面很危险?我该如何解决这个问题?另外,我什至不确定在哪里可以找到在路径中声明 /user/bin 的位置。
Thanks
谢谢
回答by Dean
$PATH is just a variable containing a string. To put something in front:
$PATH 只是一个包含字符串的变量。把东西放在前面:
% 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).
这并不危险,因为它仅适用于您打开的当前 shell(它不会影响您的系统或其他 shell 的路径)。
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.
要为您打开的所有 shell 自动更改路径,请将其放入~/.profile
. 如果此文件不存在,您可以创建它。
In ~/.profile
:
在~/.profile
:
homebrew=/usr/local/bin:/usr/local/sbin
export PATH=$homebrew:$PATH
export
makes the variable available to any child processes of the shell.
export
使该变量可用于 shell 的任何子进程。
回答by Lelouchcr
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/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
回答by iceturk22
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
这个问题应该解决
回答by pixel 67
I just created a .bashrc file and added
我刚刚创建了一个 .bashrc 文件并添加了
homebrew=/usr/local/bin:/usr/local/sbin
export PATH=$homebrew:$PATH
homebrew=/usr/local/bin:/usr/local/sbin
导出路径=$homebrew:$PATH
That seemed to have done the trick!
这似乎成功了!
回答by Slahser
Maybe OP's using zsh.
The way to solve it is edit the ~/.zshrceverytime you open itermwill load this file.
Change the words about PATH.
也许 OP 正在使用zsh。
解决方法是编辑~/ .zshrc每次打开iterm都会加载这个文件。
更改有关PATH的话。
回答by Mojo
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.
如果你真的想让它成为永久的和默认的,编辑文件 /etc/paths(使用 sudo)并将 /usr/local/bin 移动到列表的顶部。
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.
在我自己的 .bash_profile 中,我使用了一个名为“pathadd”的脚本,它可以防止我的 PATH 在 shell 分叉时变得笨拙和充满重复项。所以我采取了 /etc/paths 动作,通过一次又一次地在前面添加 /usr/local/bin 来避免在 PATH 中出现重复的目录。
回答by Даниил Пронин
You need to restart your Terminal after any change with $PATH.
使用 $PATH 进行任何更改后,您需要重新启动终端。
回答by Slava V
On OS X Mountain Lion that needed edits was ~/.bash_profile
在需要编辑的 OS X Mountain Lion 上 ~/.bash_profile