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 https://github.com/Linuxbrew/homebrew-core/issues/new
  • 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_DEV_CMD_RUN: 1
HOMEBREW_ENV_FILTERING: 1
HOMEBREW_GITHUB_API_TOKEN: set
HOMEBREW_GIT_CONFIG_DEVELOPERMODE: true
HOMEBREW_LOGS: /scratch/.cache
HOMEBREW_NO_ANALYTICS_THIS_RUN: 1
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:
  /home/linuxbrew/.linuxbrew/bin/icu-config
  /home/linuxbrew/.linuxbrew/bin/xslt-config
  /home/linuxbrew/.linuxbrew/bin/python3.6m-config
  /home/linuxbrew/.linuxbrew/bin/python2.7-config
  /home/linuxbrew/.linuxbrew/bin/Magick++-config
  /home/linuxbrew/.linuxbrew/bin/nspr-config
  /home/linuxbrew/.linuxbrew/bin/sdl2-config
  /home/linuxbrew/.linuxbrew/bin/freetype-config
  /home/linuxbrew/.linuxbrew/bin/MagickCore-config
  /home/linuxbrew/.linuxbrew/bin/libgcrypt-config
  /home/linuxbrew/.linuxbrew/bin/croco-0.6-config
  /home/linuxbrew/.linuxbrew/bin/gpg-error-config
  /home/linuxbrew/.linuxbrew/bin/gdlib-config
  /home/linuxbrew/.linuxbrew/bin/xml2-config
  /home/linuxbrew/.linuxbrew/bin/ncurses6-config
  /home/linuxbrew/.linuxbrew/bin/pkg-config
  /home/linuxbrew/.linuxbrew/bin/llvm-config
  /home/linuxbrew/.linuxbrew/bin/gsl-config
  /home/linuxbrew/.linuxbrew/bin/ncursesw6-config
  /home/linuxbrew/.linuxbrew/bin/libwmf-config
  /home/linuxbrew/.linuxbrew/bin/pcre-config
  /home/linuxbrew/.linuxbrew/bin/python3-config
  /home/linuxbrew/.linuxbrew/bin/jemalloc-config
  /home/linuxbrew/.linuxbrew/bin/caca-config
  /home/linuxbrew/.linuxbrew/bin/guile-config
  /home/linuxbrew/.linuxbrew/bin/MagickWand-config
  /home/linuxbrew/.linuxbrew/bin/python2-config
  /home/linuxbrew/.linuxbrew/bin/libpng-config
  /home/linuxbrew/.linuxbrew/bin/libpng16-config
  /home/linuxbrew/.linuxbrew/bin/wx-config
  /home/linuxbrew/.linuxbrew/bin/curl-config
  /home/linuxbrew/.linuxbrew/bin/cups-config
  /home/linuxbrew/.linuxbrew/bin/orbit2-config
  /home/linuxbrew/.linuxbrew/bin/krb5-config
  /home/linuxbrew/.linuxbrew/bin/autoopts-config
  /home/linuxbrew/.linuxbrew/bin/python3.6-config

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:

  • export HOMEBREW_NO_ENV_FILTERING=1
  • 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…

export HOMEBREW_NO_ENV_FILTERING=1

More Issues: