ruby 如何修改 Homebrew 的 PATH?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/10343834/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-06 05:04:35  来源:igfitidea点击:

How to modify PATH for Homebrew?

rubypathhomebrew

提问by mrdavidjcole

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:

尝试安装 ruby​​ 1.9.3,阅读我需要先安装自制软件。Ran brew doctor,它给了我一堆警告。其中之一是:

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.

警告:/usr/bin 出现在 /usr/local/bin 之前这意味着将使用系统提供的程序而不是 Homebrew 提供的程序。两个路径中都存在以下工具:

easy_install
easy_install-2.6

考虑修改您的 PATH,以便 /usr/local/bin 在您的 PATH 中位于 /usr/bin 之前。

How does one do what it's asking here?

一个人怎么做它在这里问的?

回答by fengd

open your /etc/paths file, put /usr/local/bin on top of /usr/bin

打开您的 /etc/paths 文件,将 /usr/local/bin 放在 /usr/bin 之上

$ sudo vi /etc/paths
/usr/local/bin
/usr/local/sbin
/usr/bin
/bin
/usr/sbin
/sbin

and Restart the terminal, @mmel

重新启动终端,@mmel

回答by avelis

There are many ways to update your path. Jun1st answer works great. Another method is to augment your .bash_profileto have:

有很多方法可以更新您的路径。Jun1st 答案效果很好。另一种方法是增加你的.bash_profile

export PATH="/usr/local/bin:/usr/local/sbin:~/bin:$PATH"

The line above places /usr/local/binand /usr/local/sbinin front of your $PATH. Once you sourceyour .bash_profileor start a new terminal you can verify your path by echo'ing it out.

上述场所的线/usr/local/bin/usr/local/sbin在你的面前$PATH。一旦你采购.bash_profile或启动一个新的终端,你可以验证你的路径回声“荷兰国际集团出来。

$ 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 doctoragain should no longer produce your error.

一旦对结果感到满意,$ brew doctor再次运行应该不再产生您的错误。

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/

这篇博文帮助我解决了遇到的问题。http://moncefbelyamani.com/how-to-install-xcode-homebrew-git-rvm-ruby-on-mac/

回答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 mycargus

To avoid unnecessary duplication, I added the following to my ~/.bash_profile

为了避免不必要的重复,我在 ~/.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

信用:https: //superuser.com/a/580611

回答by Siddhant Raut

open bash profile in textEdit

在 textEdit 中打开 bash 配置文件

open -e .bash_profile

打开 -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

编辑文件或粘贴在PATH前面导出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

*要打开 .bash_profile 直接打开 textEdit > 文件 > 最近