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

ncw*_*ncw 12 git macos homebrew path

我在OS X El Capitan上安装了Homebrew.在安装的最后几步中我应该安装git

brew install git
Run Code Online (Sandbox Code Playgroud)

这很好.现在,如果我运行'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
Run Code Online (Sandbox Code Playgroud)

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

$ brew install git 
Warning: git-2.7.4 already installed
Run Code Online (Sandbox Code Playgroud)

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

$ brew update
Warning: git-2.7.4 already installed
Error: Git must be installed and in your PATH!
Run Code Online (Sandbox Code Playgroud)

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


附加信息:

  • 哪个-git导致:

    $ which -a git
    /usr/local/bin/git
    /usr/local/bin/git
    /usr/bin/git
    
    Run Code Online (Sandbox Code Playgroud)
  • 我尝试了很多潜在的修复,同时我执行了:

    echo 'export PATH="/usr/local/bin:$PATH"' >> ~/.bash_profile
    
    Run Code Online (Sandbox Code Playgroud)

    我的〜/ .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
    
    Run Code Online (Sandbox Code Playgroud)
  • 当我尝试安装cask时:

    $ brew tap caskroom/cask
    ==> Installing git
    Warning: git-2.7.4 already installed
    Error: Git is unavailable
    
    Run Code Online (Sandbox Code Playgroud)
  • brew配置:

    $ 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
    
    Run Code Online (Sandbox Code Playgroud)

编辑:添加了其他信息.

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

Luc*_*mie 30

这解决了我的问题:

cd /usr/local/Library/Homebrew
git pull origin master
Run Code Online (Sandbox Code Playgroud)

之后我又跑了

brew update && brew upgrade
Run Code Online (Sandbox Code Playgroud)

  • 对于较新版本的MacOS,请使用`cd/usr/local/Homebrew`路径 (12认同)

Mik*_*ton 11

对我来说,这是由于缺少xcode工具引起的xcode-select --install.

其他几个建议的修复包括git fetch在brew目录和/或更改git core.autocrlf没有解决这个问题.

更详细地说,我从brew中卸载了git brew uninstall --force git,但Apple自己的git然后没有工作(/usr/bin/git --version报道missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun).

运行brew doctor建议运行xcode-select --install,我运行它,它修复了Apple的git,并且还修复了brew.(然后可以通过brew重新安装git brew install git.)