New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

brew update fails with "Git must be installed and in your PATH!" #3029

Closed
stefanscheidt opened this Issue Jul 15, 2016 · 12 comments

Comments

Projects
None yet
9 participants
@stefanscheidt
Copy link

stefanscheidt commented Jul 15, 2016

brew update fails with this error:

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

Detailed infos follows. Thanks for any help!

$ brew config
HOMEBREW_VERSION: 0.9.9
ORIGIN: https://github.com/Homebrew/brew.git
HEAD: a02be9eea204264ce48827ac365c8b53b986d66a
Last commit: 24 minutes ago
Core tap ORIGIN: https://github.com/Homebrew/homebrew-core
Core tap HEAD: 09a63d8488509fcb92b3068d79d50d708f0fefdd
Core tap last commit: 2 weeks ago
HOMEBREW_PREFIX: /usr/local
HOMEBREW_REPOSITORY: /usr/local
HOMEBREW_CELLAR: /usr/local/Cellar
HOMEBREW_BOTTLE_DOMAIN: https://homebrew.bintray.com
CPU: octa-core 64-bit haswell
Homebrew Ruby: 2.0.0-p648
Clang: 7.3 build 703
Git: 2.9.0 => /usr/local/bin/git
Perl: /usr/bin/perl
Python: /usr/bin/python
Ruby: /Users/stefanscheidt/.rbenv/shims/ruby => /Users/stefanscheidt/.rbenv/versions/2.0.0-p648/bin/ruby
Java: 1.8.0_92
OS X: 10.11.5-x86_64
Xcode: 7.3.1
CLT: N/A
X11: N/A

$ 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: You have unlinked kegs in your Cellar
Leaving kegs unlinked can lead to build-trouble and cause brews that depend on
those kegs to fail to run properly once built. Run `brew link` on these:
    ansible
    ansible19

$ brew update
Warning: git-2.9.0 already installed
Error: Git must be installed and in your PATH!
stefanscheidt@digital0379: ~
$ brew update
Warning: git-2.9.0 already installed
Error: Git must be installed and in your PATH!

$ which -a git
/usr/local/bin/git
/usr/local/bin/git
/usr/bin/git

$ echo $PATH
/Users/stefanscheidt/.sdkman/candidates/maven/current/bin:/Users/stefanscheidt/.sdkman/candidates/ant/current/bin:/Users/stefanscheidt/.rbenv/shims:/Users/stefanscheidt/.nvm/versions/node/v4.3.2/bin:.:/Users/stefanscheidt/.local/bin:/Users/stefanscheidt/local/bin:/usr/local/bin:/usr/local/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/MacGPG2/bin

DomT4 referenced this issue in Homebrew/brew Jul 15, 2016

ENV: move to new paths. (#507)
Move some stuff formerly in `Library/ENV` around:
- Move `Library/ENV/$XCODE_VERSION` to `Library/Homebrew/env/super` as they are
  all superenv wrappers and all symlinks to the same version. We never needed
  the "separate shims for separate versions" functionality and it just adds
  confusion.
- Move `Library/ENV/pkgconfig` to `Library/Homebrew/env/pkgconfig` to get more
  things under `Library/Homebrew`
- Move `Library/ENV/scm` to `Library/scm` as these wrappers are not actually
  used by or related to superenv (or stdenv) in any way.
@immortaleeb

This comment has been minimized.

Copy link

immortaleeb commented Jul 15, 2016

As of about 30 minutes ago I'm having the exact same problem...

@DomT4

This comment has been minimized.

Copy link
Contributor

DomT4 commented Jul 15, 2016

You may need to:

cd $(brew --prefix) && git fetch && git reset --hard origin/master

To escape the error. Should only need doing once if brew update remains stuck.

@MikeMcQuaid

This comment has been minimized.

Copy link
Member

MikeMcQuaid commented Jul 15, 2016

@DomT4 Don't think that's necessary any more but folks: if it is, please let me know.

@DomT4

This comment has been minimized.

Copy link
Contributor

DomT4 commented Jul 15, 2016

It seems to be, based on checking locally & our CI output. If you ended up there, can't seem to brew update successfully.

@stefanscheidt

This comment has been minimized.

Copy link
Author

stefanscheidt commented Jul 15, 2016

For me, brew update seems to work fine again!

Thanks for the super fast fix!

@hannesN

This comment has been minimized.

Copy link

hannesN commented Dec 12, 2017

I had to switch to master to get it work again, and still getting the weird message:

Warning: git 2.15.1 is already installed
Error: Git must be installed and in your PATH!
@MikeMcQuaid

This comment has been minimized.

Copy link
Member

MikeMcQuaid commented Dec 12, 2017

@hannesN What's your brew doctor and brew config output?

@timschreiner

This comment has been minimized.

Copy link

timschreiner commented Dec 12, 2017

I had the same issues as above, my brew doctor output looked like

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

Warning: No developer tools installed.
Install the Command Line Tools:
  xcode-select --install


Warning: Homebrew's sbin was not found in your PATH but you have installed
formulae that put executables in /usr/local/sbin.
Consider setting the PATH for example like so
  echo 'export PATH="/usr/local/sbin:$PATH"' >> ~/.bash_profile

I ran xcode-select --install and made sure i had /usr/local/sbin in my path and now brew's working great again.

Btw, it was working fine yesterday, I think installing macOS High Sierra last night is what tripped it up.

@DomT4

This comment has been minimized.

Copy link
Contributor

DomT4 commented Dec 14, 2017

What happens if you manually run git after the update to High Sierra? Does it throw out anything interesting?

@mirkhosro

This comment has been minimized.

Copy link

mirkhosro commented Dec 14, 2017

The above solution (xcode-select --install) fixed my issue, so I deleted my previous comment.
I do remember that running git would print an error message right after the upgrade to High Sierra, but unfortunately I cannot remember the exact error. But I managed to fix it then (again I can't remember how exactly :(

@glhrmv

This comment has been minimized.

Copy link

glhrmv commented Dec 16, 2017

I had this problem this morning, and after reading the comments here I figured it could be related to me having moved Xcode.app to the trash a few days ago. I tried some of the commands suggested here, namely xcode-select --install but nothing worked. Here's a detailed walkthrough of what I did, although I think the last step alone might fix this issue for you.

  1. Removed all Xcode.app-related leftovers, according to the commands listed in the top answer to this question (and the top comment to that answer, as well).

  2. I ran sudo rm -rf /Library/Developer/CommandLineTools which deleted my standalone version of the command line tools. You might not have this, so this command might return "No such file or directory". This is fine.

  3. I (re)installed the standalone command line tools with xcode-select --install. This still didn't fix Homebrew finding git for me, so I then read the man page for xcode-select and I did...

  4. sudo xcode-select -r. This should make your brew doctor output "ready to brew".

You might also need to update the newly installed command line tools with the App Store; a new update should show up in the "Updates" section.

@Benjamin-Connelly

This comment has been minimized.

Copy link

Benjamin-Connelly commented Dec 20, 2017

I just ran into the same problem. The following two commands fixed the issue for me:

sudo xcode-select -r
xcode-select --install

@Homebrew Homebrew deleted a comment from kevinfletcher Mar 21, 2018

@Homebrew Homebrew locked as resolved and limited conversation to collaborators Mar 21, 2018

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.