Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 588
tzarsmango Avatar asked Mar 10 '21 08:03

tzarsmango


2 Answers

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.

like image 84
interesting_matt Avatar answered Nov 07 '22 11:11

interesting_matt


This happened to me today (also on Virgin Media). An alternative to using a VPN (especially if you don't want to pay for one) is simply to change your chosen DNS servers to a free public one such as Google's as described here. Tldr; set them to one or both of 8.8.4.4 and 8.8.8.8 and the command should work. You can then (if you wish) change back to your router's default.

like image 1
Tom Bush Avatar answered Nov 07 '22 11:11

Tom Bush