Search code examples
gitmacoshomebrewfatal-error

Homebrew Update Fails: fatal: protocol error: bad pack header on git fetch


When I try to update (or upgrade brew) I get the following error:

#> brew update
Error:
  homebrew-core is a shallow clone.
To `brew update`, first run:
  git -C /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core fetch --unshallow
This command may take a few minutes to run due to the large size of the repository.
This restriction has been made on GitHub's request because updating shallow
clones is an extremely expensive operation due to the tree layout and traffic of
Homebrew/homebrew-core and Homebrew/homebrew-cask. We don't do this for you
automatically to avoid repeatedly performing an expensive unshallow operation in
CI systems (which should instead be fixed to not use shallow clones). Sorry for
the inconvenience!

and when I run the indicated command I get another error:

#> git -C /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core fetch --unshallow
fatal: protocol error: bad pack header

I'm using macOS Big Sur V11.2.3. I have BitDefender as the anti-virus software. I tried disabling it and run the above command but with no luck. Any help would be appreciated.


Solution

  • I found some pages suggesting this was caused by an "anti-virus" software setting enabled by my ISP (Virgin Media in the UK). I turned off "Virus Safe" at https://my.virginmedia.com/my-apps/onlinesecurity/websafe/settings but that didn't fix the issue for me.

    Then, I turned on my VPN (NordVPN), and the brew command causing the problem worked.