brew doctor 警告:如何将 git 添加到 PATH?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/36237537/
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 Warning: How to add git to PATH?
提问by ncw
I installed Homebrew on OS X El Capitan. In the last steps of the installation I was supposed to install git with
我在 OS X El Capitan 上安装了 Homebrew。在安装的最后一步中,我应该安装 git
brew install git
which was fine. Now if I run 'brew doctor' this happens:
这很好。现在,如果我运行 'brew doctor',就会发生这种情况:
$ brew doctor
Please note that these warnings are just used to help the Homebrew maintainers
with debugging if you file an issue. If everything you use Homebrew for is
working fine: please don't worry and just ignore them. Thanks!
Warning: Git could not be found in your PATH.
Homebrew uses Git for several internal functions, and some formulae use Git
checkouts instead of stable tarballs. You may want to install Git:
brew install git
If I run 'brew install git' again, I get:
如果我再次运行“brew install git”,我会得到:
$ brew install git
Warning: git-2.7.4 already installed
So needless to say my git version is 2.7.4. 'brew update' throws:
所以不用说我的 git 版本是 2.7.4。“酿造更新”抛出:
$ brew update
Warning: git-2.7.4 already installed
Error: Git must be installed and in your PATH!
Question:How do I fix my PATH so git can be found in my PATH and 'brew doctor' results in 'Your system is ready to brew'?
问题:如何修复我的 PATH 以便可以在我的 PATH 中找到 git 并且“brew doctor”结果为“您的系统已准备好进行 brew”?
Additional Information:
附加信息:
which -a git results in:
$ which -a git /usr/local/bin/git /usr/local/bin/git /usr/bin/git
I tried a lot of potential fixes, meanwhile I executed:
echo 'export PATH="/usr/local/bin:$PATH"' >> ~/.bash_profile
My ~/.bash_profile now looks like this:
# Setting PATH for Python 2.7 # The orginal version is saved in .bash_profile.pysave PATH="/Library/Frameworks/Python.framework/Versions/2.7/bin:${PATH}" export PATH=/usr/local/bin:$PATH
When I try to install cask:
$ brew tap caskroom/cask ==> Installing git Warning: git-2.7.4 already installed Error: Git is unavailable
brew config:
$ brew config HOMEBREW_VERSION: 0.9.5 ORIGIN: (none) HEAD: (none) Last commit: never HOMEBREW_PREFIX: /usr/local HOMEBREW_REPOSITORY: /usr/local HOMEBREW_CELLAR: /usr/local/Cellar HOMEBREW_BOTTLE_DOMAIN: https://homebrew.bintray.com CPU: quad-core 64-bit haswell OS X: 10.11.4-x86_64 Xcode: 7.3 CLT: 7.3.0.0.1.1457485338 Clang: 7.3 build 703 X11: N/A System Ruby: 2.0.0-p648 Perl: /usr/bin/perl Python: /usr/local/bin/python => /usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/bin/python2.7 Ruby: /usr/bin/ruby => /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby Java: 1.8.0_40
which -a git 结果:
$ which -a git /usr/local/bin/git /usr/local/bin/git /usr/bin/git
我尝试了很多潜在的修复,同时我执行了:
echo 'export PATH="/usr/local/bin:$PATH"' >> ~/.bash_profile
我的 ~/.bash_profile 现在看起来像这样:
# Setting PATH for Python 2.7 # The orginal version is saved in .bash_profile.pysave PATH="/Library/Frameworks/Python.framework/Versions/2.7/bin:${PATH}" export PATH=/usr/local/bin:$PATH
当我尝试安装桶时:
$ brew tap caskroom/cask ==> Installing git Warning: git-2.7.4 already installed Error: Git is unavailable
酿造配置:
$ brew config HOMEBREW_VERSION: 0.9.5 ORIGIN: (none) HEAD: (none) Last commit: never HOMEBREW_PREFIX: /usr/local HOMEBREW_REPOSITORY: /usr/local HOMEBREW_CELLAR: /usr/local/Cellar HOMEBREW_BOTTLE_DOMAIN: https://homebrew.bintray.com CPU: quad-core 64-bit haswell OS X: 10.11.4-x86_64 Xcode: 7.3 CLT: 7.3.0.0.1.1457485338 Clang: 7.3 build 703 X11: N/A System Ruby: 2.0.0-p648 Perl: /usr/bin/perl Python: /usr/local/bin/python => /usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/bin/python2.7 Ruby: /usr/bin/ruby => /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby Java: 1.8.0_40
EDIT: Added cask to additional information.
编辑:在附加信息中添加了木桶。
EDIT2: Added brew config and added brew doctor prefix
EDIT2:添加了 brew 配置并添加了 brew doctor 前缀
回答by Lucian Irimie
this fixed my problem:
这解决了我的问题:
cd /usr/local/Library/Homebrew
git pull origin master
after that I ran again
之后我又跑了
brew update && brew upgrade
回答by MikeBeaton
For me this was caused by missing xcode tools, fixed by xcode-select --install
.
对我来说,这是由于缺少 xcode 工具引起的,由xcode-select --install
.
Several other suggested fixes including git fetch
in the brew directory and/or changing git core.autocrlf
did not fix this.
包括git fetch
brew 目录和/或更改 git在内的其他几个建议的修复程序core.autocrlf
没有解决这个问题。
In more detail I uninstalled git from brew brew uninstall --force git
, but Apple's own git then didn't work (/usr/bin/git --version
reported missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
).
更详细地说,我从 brew 卸载了 git brew uninstall --force git
,但是 Apple 自己的 git 没有工作(/usr/bin/git --version
报告missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
)。
Running brew doctor
suggested running xcode-select --install
, I ran this and it fixed Apple's git, and also fixed brew. (Possible to then reinstall git via brew brew install git
.)
Runningbrew doctor
建议 running xcode-select --install
,我运行了它,它修复了 Apple 的 git,还修复了 brew。(然后可以通过 brew 重新安装 git brew install git
。)
回答by TheGeorgeous
Simply run:
只需运行:
export PATH=/usr/local/bin:$PATH
Your PATH
variable should look something like
你的PATH
变量应该看起来像
PATH="/usr/bin:/usr/local/bin"
回答by ncw
I found the solution to my problem. It was caused by a wrong fileformat of /usr/local/Library/ENV/scm/git
:
我找到了解决我的问题的方法。这是由错误的文件格式引起的/usr/local/Library/ENV/scm/git
:
$ /usr/local/Library/ENV/scm/git --version
-bash: /usr/local/Library/ENV/scm/git: /bin/sh^M: bad interpreter: No such file or directory
So I edited the fileformat:
所以我编辑了文件格式:
$ vi /usr/local/Library/ENV/scm/git
Press 'ESC', write :set fileformat=unix
, Press 'Enter', write :wq!
.
按“ESC”,写:set fileformat=unix
,按“Enter”,写:wq!
。
That fixed it for me.
那为我修好了。
回答by jalanb
I ran into the same symptom when tyring to run brew update
.
我在跑步时遇到了同样的症状brew update
。
In my case problem was caused by have a bash variable of GIT
set (to a directory). So the solution was to unset it for the brew command
在我的情况下,问题是由设置的 bash 变量GIT
(到目录)引起的。所以解决方案是为 brew 命令取消设置
$ GIT= brew update
回答by rapttor
Likely problem with libintl.8.dylib as in many other similar issues:
与许多其他类似问题一样,libintl.8.dylib 可能存在问题:
locate libintl.8.dylib
if /gettext//libintl.*.dylib exists
如果/gettext//libintl.*.dylib 存在
brew link -f gettext
go to (depending on version)
转到(取决于版本)
cd /usr/local/Homebrew
cd /usr/local/Library/Homebrew
and execute (make sure you're in .../Homebrew directory)
并执行(确保你在 .../Homebrew 目录中)
git pull origin master
rm -fr ".git/rebase-apply"
brew update && brew upgrade
this last will took some time, but afterwards everything should work fine.
这最后需要一些时间,但之后一切都应该正常工作。
回答by Sandeep M
If you're like me: using macOS El Capitan and don't have /usr/local/Library/ENV/scm/git
, here's what you can do.
如果您像我一样:使用 macOS El Capitan 而没有/usr/local/Library/ENV/scm/git
,您可以执行以下操作。
cd /usr/local/
# The folder where you've installed Homebrew
git config --list --local
Look for: core.autoxrlf=false
寻找: core.autoxrlf=false
If don't see it run: git config --local core.autocrlf false
如果没有看到它运行: git config --local core.autocrlf false
Then run:
然后运行:
git fetch origin
git reset --hard origin/master
brew update