Solvedbrew brew update failed with "Error: Git must be installed and in your PATH!"

Please fill out the issue checklist below, and provide all of the requested information.

Please always follow these steps:

  • Confirmed this is a problem with running a brew command and not brew installing or the post-install behaviour of one or more formulae? If it's a formulae-specific problem please file this issue at the relevant tap e.g. for Linuxbrew/homebrew-core
  • Ran brew update and retried your prior step?
  • Ran brew doctor, fixed all issues and retried your prior step?
  • Ran brew config and brew doctor and included their output with your issue?

To help us debug your issue please explain:
brew update gives:

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

I tried remove git by brew uninstall --force git and reinstall using brew install git and it ended up the same.
Note that I have to install linuxbrew in /scratch/.linuxbrew and symlink that directory to /home/linuxbrew/.linuxbrew but other than that there's nothing special in my linuxbrew setup. Also, I noticed there was a homebrew issue: Homebrew/homebrew-core#3029 and I'm not sure if it's related because linuxbrew has been working fine until a recently.
Here's the output from brew config:

HOMEBREW_VERSION: >1.2.0 (shallow or no git repository)
ORIGIN: (none)
HEAD: (none)
Last commit: never
Core tap ORIGIN: (none)
Core tap HEAD: (none)
Core tap last commit: never
HOMEBREW_PREFIX: /scratch/.linuxbrew
HOMEBREW_REPOSITORY: /scratch/.linuxbrew/Homebrew
HOMEBREW_CELLAR: /scratch/.linuxbrew/Cellar
HOMEBREW_CACHE: /scratch/.cache
HOMEBREW_CELLAR: /scratch/.linuxbrew/Cellar
HOMEBREW_LOGS: /scratch/.cache
HOMEBREW_PREFIX: /scratch/.linuxbrew
HOMEBREW_REPOSITORY: /scratch/.linuxbrew/Homebrew
HOMEBREW_TEMP: /scratch/tmp
CPU: quad-core 64-bit skylake
Homebrew Ruby: 2.3.3 => /scratch/.linuxbrew/Homebrew/Library/Homebrew/vendor/portable-ruby/2.3.3/bin/ruby
Clang: 5.0 build 
Git: N/A
Curl: 7.57.0 => /scratch/.linuxbrew/opt/curl/bin/curl
Perl: /home/linuxbrew/.linuxbrew/bin/perl => /scratch/.linuxbrew/Cellar/perl/5.26.1/bin/perl
Python: /scratch/.linuxbrew/opt/python/libexec/bin/python => /scratch/.linuxbrew/Cellar/python/2.7.14/bin/python2.7
Ruby: /home/linuxbrew/.linuxbrew/bin/ruby => /scratch/.linuxbrew/Cellar/ruby/2.4.2/bin/ruby
Java: openjdk version "1.8.0_144"
Kernel: Linux 2.6.32-696.13.2.el6.x86_64 x86_64 GNU/Linux
OS: CentOS release 6.9 (Final) (Final)
Host glibc: 2.12
/usr/bin/gcc: 4.4.7
glibc: 2.23
gcc: 5.4.0
xorg: 20170115

Here's the output of 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: "config" scripts exist outside your system or Homebrew directories.
`./configure` scripts often look for *-config scripts to determine if
software packages are installed, and what additional flags to use when
compiling and linking.

Having additional scripts in your path can confuse software installed via
Homebrew if the config script overrides a system or Homebrew provided
script of the same name. We found the following "config" scripts:

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
Warning: Use tcl-tk instead of deprecated homebrew/dupes/tcl-tk
Warning: Use tcl-tk instead of deprecated homebrew/dupes/tcl-tk
  • Step-by-step reproduction instructions (by running brew commands)
    just run brew update
32 Answers

✔️Accepted Answer

Possibly related: I reproduced the same on High Sierra, and after performing the HOMEBREW_NO_ENV_FILTERING=1 hack, I managed to make some progress; then I noticed the following message:

xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun

...and so I am wondering if — because I need to update Xcode — the env-filtering code is perhaps aborting part-way-through, and somehow corrupting the PATH which Brew uses, and then failing to find Git?

UPDATE: it appears to have been fixed, after doing:

  • xcode-select --install
  • brew update
  • brew upgrade

...and then starting a new Terminal shell to try a fresh environment

Other Answers:

As a work around for now, set…


More Issues: