19

I installed Homebrew on OS X El Capitan. In the last steps of the installation I was supposed to install git with

brew install git

which was fine. Now if I run 'brew doctor' this happens:

$ 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 
Warning: git-2.7.4 already installed

So needless to say my git version is 2.7.4. 'brew update' throws:

$ 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'?


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
    

EDIT: Added cask to additional information.

EDIT2: Added brew config and added brew doctor prefix

ncw
  • 1,635
  • 1
  • 18
  • 26
  • Please also post the full output of `brew doctor` and `brew config`. – bfontaine Mar 28 '16 at 15:10
  • @bfontaine I added the `brew config` and completed the `brew doctor` (the general note about homebrew warnings, which I considered as unimportant in the first place). – ncw Mar 28 '16 at 18:11
  • Thanks; does `source ~/.bash_profile` fix the issue? – bfontaine Mar 28 '16 at 22:05
  • Unfortunately not. I tried it 2 days ago along with TheGeorgeous' approach, but it didn't work. I also tried it a few seconds ago, `brew doctor` still provides the same output – ncw Mar 28 '16 at 22:08
  • What is the output of `brew info git`? – bfontaine Mar 29 '16 at 09:41
  • I fixed it, see my accepted answer. Thanks for your help @bfontaine! – ncw Mar 29 '16 at 14:58

7 Answers7

32

First, change directory to /usr/local/Homebrew in the Terminal (for older versions of MacOS, use cd cd /usr/local/Library/Homebrew). Then run:

git pull origin master
brew update && brew upgrade
tog22
  • 486
  • 1
  • 4
  • 21
Lucian Irimie
  • 814
  • 15
  • 19
14

For me this was caused by missing xcode tools, fixed by xcode-select --install.

Several other suggested fixes including git fetch in the brew directory and/or changing git core.autocrlf did not fix this.

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).

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.)

MikeBeaton
  • 3,314
  • 4
  • 36
  • 45
  • 1
    I just updated to macOS Mojave and I had to reinstall the Xcode command-line tools to get brew (and git) going again – Chris Sep 28 '18 at 21:56
  • This works and is the answer for me. Why is the "answer" doing a git pull manually, when the whole essence of using a package manager is not to do anything manually, even for homebrew. Tsk tsk – jumping_monkey Oct 06 '19 at 04:09
1

Simply run:

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

Your PATH variable should look something like

PATH="/usr/bin:/usr/local/bin"
TheGeorgeous
  • 3,927
  • 2
  • 20
  • 33
  • Didn't work unfortunately; I ran the command `export PATH=/usr/local/bin:$PATH` but this didn't change anything in my ~/.bash_profile. After that I manually changed the ~/.bash_profile to look like this: `PATH="/usr/bin:/usr/local/bin"` `export PATH=/usr/local/bin:$PATH` If I completely misunderstood your answer, be gentle. I don't have that much experience with unix terminals – ncw Mar 26 '16 at 18:38
  • Have you checked your `.bashrc`? Also you will have to run `source .bashrc` to reload your configuration – TheGeorgeous Mar 26 '16 at 18:44
  • If I run `source .bashrc`it says `No such file or directory`. I simply closed and reopened my terminal to reload the configuration. As far as I know, in this case I only have to look for the .bash_profile and set the PATH correctly so the git will be found by brew? – ncw Mar 26 '16 at 21:46
1

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 --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!.

That fixed it for me.

ncw
  • 1,635
  • 1
  • 18
  • 26
1

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.

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

Look for: core.autoxrlf=false

If don't see it run: git config --local core.autocrlf false

Then run:

git fetch origin
git reset --hard origin/master
brew update
Sandeep M
  • 2,942
  • 2
  • 13
  • 17
0

I ran into the same symptom when tyring to run 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

$ GIT= brew update
jalanb
  • 1,097
  • 2
  • 11
  • 37
0

Likely problem with libintl.8.dylib as in many other similar issues:

locate libintl.8.dylib

if /gettext//libintl.*.dylib exists

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)

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.

rapttor
  • 396
  • 3
  • 7