brew doctor警告:如何在PATH中添加git?

时间:2016-03-26 16:07:43

标签: git macos path homebrew

我在OS X El Capitan上安装了Homebrew。在安装的最后几步中,我应该用

安装git
brew install git

这很好。现在,如果我运行“酿造医生”,就会发生这种情况:

$ 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

如果我再次运行'brew install git',我会得到:

$ brew install git 
Warning: git-2.7.4 already installed

所以不用说我的git版本是2.7.4。 'brew update'抛出:

$ brew update
Warning: git-2.7.4 already installed
Error: Git must be installed and in your PATH!

问题:如何修复我的PATH,以便在我的PATH中找到git,并且'brew doctor'结果为'您的系统已准备好酿造'?

其他信息:

  • -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
    
  • 当我尝试安装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
    

编辑:添加了其他信息。

EDIT2:添加了brew配置并添加了brew doctor前缀

7 个答案:

答案 0 :(得分:25)

这解决了我的问题:

cd /usr/local/Library/Homebrew
git pull origin master
之后我又跑了

brew update && brew upgrade

答案 1 :(得分:10)

对我而言,这是由于缺少xcode工具造成的,由<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.2.3/jquery.min.js"></script> <div class='wrapper'> <article> text <br> text </article> <aside> <img src="https://static.pexels.com/photos/248797/pexels-photo-248797.jpeg"> </aside> </div>修复。

brew目录中包含xcode-select --install和/或更改git git fetch的其他一些建议修补程序无法解决此问题。

更详细地说,我从brew core.autocrlf卸载了git,但是Apple自己的git然后无效(brew uninstall --force git报告了/usr/bin/git --version)。

运行missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun建议运行brew doctor,我运行了这个并修复了Apple的git,并修复了brew。 (然后可以通过brew xcode-select --install重新安装git。)

答案 2 :(得分:1)

简单地运行:

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

您的PATH变量应该类似于

PATH="/usr/bin:/usr/local/bin"

答案 3 :(得分:1)

我找到了解决问题的方法。它是由/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

所以我编辑了fileformat:

$ vi /usr/local/Library/ENV/scm/git

按&#39; ESC&#39;,写:set fileformat=unix,按&#39;输入&#39;,写:wq!

为我修好了。

答案 4 :(得分:0)

在设置;;;;; <td>empty</td> <td>testvalue</td> <td>testvalue</td> <td>test"val"ue</td> <td>test value</td> <td>empty</td> 时,我遇到了相同的症状。

在我的情况下,问题是由于brew update的bash变量设置(到目录)引起的。因此解决方案是为brew命令取消设置

GIT

答案 5 :(得分:0)

如果你像我一样:使用macOS El Capitan并且没有/usr/local/Library/ENV/scm/git,这就是你能做的。

cd /usr/local/
# The folder where you've installed Homebrew
git config --list --local

寻找:core.autoxrlf=false

如果看不到它:git config --local core.autocrlf false

然后运行:

git fetch origin
git reset --hard origin/master
brew update

答案 6 :(得分:0)

与其他许多类似问题一样,libintl.8.dylib的问题类似:

locate libintl.8.dylib

如果 / gettext / / libintl。*。dylib存在

brew link -f gettext

转到(取决于版本)

cd /usr/local/Homebrew 
cd /usr/local/Library/Homebrew 

并执行(确保您位于... / Homebrew目录中)

git pull origin master
rm -fr ".git/rebase-apply"
brew update && brew upgrade

这最后一个过程要花一些时间,但是之后一切都应该正常工作。