Skip to content
This repository has been archived by the owner on Jul 4, 2023. It is now read-only.

brew doctor Warning: How to add git to PATH? #50500

Closed
ncvv opened this issue Mar 29, 2016 · 10 comments
Closed

brew doctor Warning: How to add git to PATH? #50500

ncvv opened this issue Mar 29, 2016 · 10 comments

Comments

@ncvv
Copy link

ncvv commented Mar 29, 2016

First of all, I already posted this as a question at StackOverFlow, which can be found here. I don't want to exploit anybody and I apologize for posting this on more than one forum. I hope you understand why I did this is because I guess this is a very specific homebrew issue and here is the best place (which I should've chosen in the first place) for my problem. My Issue:

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!

Issue: 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:

    export PATH="/usr/local:$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
    

Thanks in advance for any help!

@dunn
Copy link
Contributor

dunn commented Mar 29, 2016

How did you install Homebrew?

What does echo $PATH give you?

@ncvv
Copy link
Author

ncvv commented Mar 29, 2016

I installed Homebrew with
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
from brew.sh

$ echo $PATH returns /usr/local/bin:/usr/local:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin

@evantill
Copy link
Contributor

@ncvv what's the output of /usr/local/Library/ENV/scm/git --version and git --versionon your system ?

(I know that you have installed git version 2.7.4)

@ncvv
Copy link
Author

ncvv commented Mar 29, 2016

I got it! Thank you, the command /usr/local/Library/ENV/scm/git --version was enough to find the solution:

The output of
$ /usr/local/Library/ENV/scm/git --version was
-bash: /usr/local/Library/ENV/scm/git: /bin/sh^M: bad interpreter: No such file or directory

I had this problem with several brew files before and the /bin/sh^M indicates the wrong fileformat (I think it's Windows?). So what I did is
vi /usr/local/Library/ENV/scm/git
and then after pressing ESC
:set fileformat=unix and finally :wq!

ran brew doctor again which gave me:
$ 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: Suspicious Git newline settings found.

The detected Git newline settings will cause checkout problems: core.autocrlf = true

If you are not routinely dealing with Windows-based projects, consider removing these by running:
git config --global core.autocrlf input

Warning: You have uncommitted modifications to Homebrew If this is a surprise to you, then you should stash these modifications. Stashing returns Homebrew to a pristine state but can be undone should you later need to do so for some reason.
cd /usr/local/Library && git stash && git clean -d -f

Warning: Your Homebrew is outdated. You haven't updated for at least 24 hours. This is a long time in brewland! To update Homebrew, run brew update.

I executed these commands and it worked, brew doctor now says Your system is ready to brew.
I don't exactly remember in which files I had to also change the fileformat to unix but this seems kinda weird to me.
Anyways, your help is very much appreciated and maybe you can figure out if this fileformat thing was my fault or if it's a general bug.

EDIT: Completely forgot to answer your initial question:
$ git --version is
git version 2.7.4

$ /usr/local/Library/ENV/scm/git --version
git: The build tool has reset ENV; --env=std required.

and $ /usr/local/Library/ENV/scm/git --version --env=std also gives
git: The build tool has reset ENV; --env=std required.

@evantill
Copy link
Contributor

the problem you have is in your git configuration.

As brew doctor complain: The detected Git newline settings will cause checkout problems: core.autocrlf = true

You need to change you git global setting or you will continue to have problems.

can you show us the output of git config --list --global ?

or better, can you post the contents of your ~/.gitconfig?

@ncvv
Copy link
Author

ncvv commented Mar 29, 2016

$ git config --list --global
core.excludesfile=/Users/username/.gitignore_global
core.autocrlf=input
difftool.sourcetree.cmd=opendiff "$LOCAL" "$REMOTE"
difftool.sourcetree.path=
mergetool.sourcetree.cmd=/Applications/SourceTree.app/Contents/Resources/opendiff-w.sh "$LOCAL" "$REMOTE" -ancestor "$BASE" -merge "$MERGED"
mergetool.sourcetree.trustexitcode=true
user.email=myemail
user.name=myrealname
github.user=ncw

Also why is the github.user different from my username (ncvv)? This is weird, I took the username ncvv because ncw was taken (apparently by ncw)

@xu-cheng
Copy link
Member

I suggest you to

git config --global core.autocrlf input
cd /usr/local
git config core.autocrlf false
git fetch origin
git reset --hard origin/master

@ncvv
Copy link
Author

ncvv commented Mar 29, 2016

@xu-cheng I did.

/usr/local/Library/ENV/scm/git --version still returns
git: The build tool has reset ENV; --env=std required.

The output of $ git config --list --global is still the same

@xu-cheng
Copy link
Member

/usr/local/Library/ENV/scm/git isn't mean to be called directly. Please check whether brew update work and brew doctor after the fix.

@ncvv
Copy link
Author

ncvv commented Mar 29, 2016

Okay. Everything is fine then, since both commands work. Thank you all very much!

@Homebrew Homebrew locked and limited conversation to collaborators Jul 10, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants