Fatal: --local can only be used inside a git repository

Hi everyone,

I recently started seeing the following messages on almost any brew command:

fatal: --local can only be used inside a git repository
fatal: --local can only be used inside a git repository
fatal: not a git repository (or any of the parent directories): .git

It happens while running:

  • brew upgrade
  • brew cask upgrade
  • brew cleanup
  • brew doctor

This is my brew doctor output:

brew doctor
fatal: --local can only be used inside a git repository
fatal: --local can only be used inside a git repository
fatal: not a git repository (or any of the parent directories): .git
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 or file an issue; just ignore this. 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:
  python@2

And brew config:

HOMEBREW_VERSION: 2.2.12
ORIGIN: https://github.com/Homebrew/brew
HEAD: 2ae26808a6793c78f749835aed2ab84cd2fa6544
Last commit: 21 hours ago
Core tap ORIGIN: https://github.com/Homebrew/homebrew-core
Core tap HEAD: 2e2df5d75fcc3080698d5360b574b2f439d543e3
Core tap last commit: 75 minutes ago
HOMEBREW_PREFIX: /usr/local
HOMEBREW_EDITOR: micro
HOMEBREW_MAKE_JOBS: 8
CPU: octa-core 64-bit kabylake
Homebrew Ruby: 2.6.3 => /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/ruby
Clang: 11.0 build 1103
Git: 2.26.0 => /usr/local/bin/git
Curl: 7.64.1 => /usr/bin/curl
Java: 14
macOS: 10.15.4-x86_64
CLT: 11.4.0.0.1.1583798712
Xcode: N/A

One thing I did is I uninstalled XCode as I don’t need it and instead only installed command line utilities from Apple Developer site. So running xcode-select --install looks fine:

xcode-select --install
xcode-select: error: command line tools are already installed, use "Software Update" to install updates
xcode-select -p
/Library/Developer/CommandLineTools
ls -al $(xcode-select -p)
total 0
drwxr-xr-x  5 root  admin  160 Oct 19 21:05 .
drwxr-xr-x  4 root  admin  128 Oct 16 19:49 ..
drwxr-xr-x  6 root  wheel  192 Sep  6  2019 Library
drwxr-xr-x  6 root  wheel  192 Apr  8 17:00 SDKs
drwxr-xr-x  7 root  admin  224 Oct 19 21:05 usr
xcode-select --version
xcode-select version 2373.

Any help would be greatly appreciated.

I finally figured it out. It was caused by aws-rotate-iam-keys formula. Running brew upgrade --verbose --debug pointed me in the right direction:

...
/usr/local/Homebrew/Library/Homebrew/brew.rb (Formulary::FormulaLoader): loading /usr/local/opt/aws-rotate-iam-keys/.brew/aws-rotate-iam-keys.rb
fatal: --local can only be used inside a git repository
fatal: --local can only be used inside a git repository
fatal: not a git repository (or any of the parent directories): .git
...
1 Like