无法更新或升级 Homebrew
Posted
技术标签:
【中文标题】无法更新或升级 Homebrew【英文标题】:Can't update or upgrade Homebrew 【发布时间】:2021-12-31 06:17:39 【问题描述】:我无法再运行 brew upgrade
或 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
如果我按照这个建议运行git ... --unshallow
,然后尝试brew update
或brew upgrade
,我仍然会收到相同的错误消息。
如果我再次尝试该命令(也许我第一次没有做对?)我得到
fatal: --unshallow on a complete repository does not make sense
如何通过此错误消息运行brew upgrade
或brew update
而不会出现错误?
HOMEBREW_VERSION: 2.6.0-82-gde1afcb
ORIGIN: https://github.com/Homebrew/brew.git
HEAD: de1afcbfc58fb3cd5779bd8fbb6b9995700dda4c
Last commit: 30 hours ago
Core tap ORIGIN: https://github.com/Homebrew/homebrew-core
Core tap HEAD: a7c63b0f7f7ae416a2f961b263155281759ac3a7
Core tap last commit: 29 hours ago
Core tap branch: master
HOMEBREW_PREFIX: /usr/local
HOMEBREW_CASK_OPTS: []
HOMEBREW_DISPLAY: /private/tmp/com.apple.launchd.FwPJPzeLfq/org.macosforge.xquartz:0
HOMEBREW_EDITOR: /usr/local/bin/bbedit
HOMEBREW_MAKE_JOBS: 4
HOMEBREW_NO_ANALYTICS: set
HOMEBREW_NO_EMOJI: set
Homebrew Ruby: 2.6.3 => /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/ruby
CPU: quad-core 64-bit haswell
Clang: 12.0 build 1200
Git: 2.29.2 => /usr/local/bin/git
Curl: 7.64.1 => /usr/bin/curl
Java: 1.8.0_172
macOS: 10.15.7-x86_64
CLT: 12.0.32.27
Xcode: 12.2
XQuartz: 2.7.11 => /opt/X11
【问题讨论】:
【参考方案1】:它要求你将homebrew-core
和 homebrew-cask
都去掉:
git -C "/usr/local/Homebrew/Library/Taps/homebrew/homebrew-core" fetch --unshallow
git -C "/usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask" fetch --unshallow
【讨论】:
它解决了我的问题。现在 'brew upgrade && brew upgrade --cask' 工作正常。谢谢。 在我的情况下,只有第一个命令被请求返回 brew update。 浅的和不浅的有什么区别? 当我尝试git homebrew-core
命令时,我收到以下错误:fatal: the remote end hung up unexpectedly fatal: protocol error: bad pack header
有什么想法吗?
@RicardoSanchez 存储库非常大,我有同样的行为,在详细移动 (-v) 上运行 git 命令,一段时间后你应该会看到一些进展。 git -C "/path/to/repo" fetch --unshallow -v
【参考方案2】:
在我这样做之前,我没有任何工作:
cd /usr/local/Homebrew/Library/Taps/homebrew/
rm -rf homebrew-core
git clone https://github.com/Homebrew/homebrew-core.git
【讨论】:
这对我有帮助。fetch --unshallow
会卡住,这对我有用
我整天都在尝试另一种方法,但它不起作用,这对我很有帮助。
这对我有用,非常感谢我花了 1 小时找到获取最新存储库的正确方法
就是这样!【参考方案3】:
似乎已经是change in the Homebrew policy,并且不会再有浅层克隆了。
正确答案是 unshallow,按照要求 — 请参阅 Eric3 answer — 或重新安装它,这将生成 repo 的 unshallow / 常规副本。
【讨论】:
【参考方案4】:这对我有用。
git -C "/usr/local/Homebrew/Library/Taps/homebrew/homebrew-core" fetch --unshallow
git -C "/usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask" fetch --unshallow
remote: Enumerating objects: 561296, done.
remote: Counting objects: 100% (561255/561255), done.
remote: Compressing objects: 100% (200847/200847), done.
remote: Total 552295 (delta 355423), reused 545449 (delta 348597), pack-reused 0
Receiving objects: 100% (552295/552295), 214.42 MiB | 2.60 MiB/s, done.
Resolving deltas: 100% (355423/355423), completed with 4915 local objects.
From https://github.com/Homebrew/homebrew-core
09e19b5c825..003302f81db master -> origin/master
remote: Enumerating objects: 180904, done.
remote: Counting objects: 100% (166460/166460), done.
remote: Compressing objects: 100% (47394/47394), done.
remote: Total 155334 (delta 116608), reused 146431 (delta 107784), pack-reused 0
Receiving objects: 100% (155334/155334), 73.84 MiB | 4.87 MiB/s, done.
Resolving deltas: 100% (116608/116608), completed with 6054 local objects.
From https://github.com/Homebrew/homebrew-cask
【讨论】:
以上是关于无法更新或升级 Homebrew的主要内容,如果未能解决你的问题,请参考以下文章