Homebrew 更新失败:git fetch 时出现“fatal: protocol error: bad pack header”的错误。

11
当我尝试更新(或升级brew)时,会出现以下错误:
#> 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!

当我运行指定的命令时,我收到另一个错误:

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

我使用的是macOS Big Sur V11.2.3操作系统,并且安装了BitDefender杀毒软件。我曾尝试关闭杀毒软件并运行上述命令,但没有成功。如有帮助将不胜感激。
4个回答

8
我发现一些页面表明这是由我的互联网服务提供商(英国的Virgin Media)启用的“杀毒软件”设置引起的。我在https://my.virginmedia.com/my-apps/onlinesecurity/websafe/settings关闭了“病毒安全”选项,但这对我没有解决问题。

然后,我开启了我的VPN(NordVPN),导致问题的brew命令就可以正常工作了。


3
这解决了我的问题。我可能永远不会想到启用 VPN 来解决这个问题。 - tzarsmango
1
谢谢。真不敢相信这会发生。在我的情况下,我不需要 VPN。我关闭了病毒安全和儿童安全,然后它就可以工作了。 - Jim Bob
没错,这对我也起作用了 - 非常感谢。我的ISP是TalkTalk(英国)。我只是关闭了所有的家庭安全功能。和@JimBob一样,我不需要VPN步骤。 - Super Symmetry

4
在我的情况下,只是跑步。
brew doctor

修复所有问题后,问题对我来说得到了解决。我认为需要解决的两个重要问题是:
警告:您有一个不必要的本地 Cask tap。这可能导致安装最新的 casks 出现问题。请通过运行以下命令移除它: brew untap homebrew/cask
警告:您有一个不必要的本地 Core tap!这可能导致安装最新的 formulae 出现问题。请通过运行以下命令移除它: brew untap homebrew/core

2
今天我也遇到了这种情况(在Virgin Media上)。与使用VPN相比的一种替代方法(特别是如果您不想支付VPN费用)就是将您选择的DNS服务器更改为免费公共DNS服务器,例如Google的 如此所述。简而言之,将DNS服务器设置为8.8.4.4和/或8.8.8.8,命令应该可以运行。然后,您可以(如果愿意)改回路由器的默认设置。

谢谢。我之前开了Burp Suite代理。关闭代理解决了问题。 - piepi

0
我搜索了很久才找到解决方案,有些人说这是内存问题(但实际上不是)。只有上面的评论帮助我解决了Virgin Media wifi的问题,所以我改用移动数据。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接