0%

[2021.01.06 亲测] Mac 解决 brew 一直卡在 Updating Homebrew

执行brew install时,一直卡在Updating Homebrew...,虽然ctrl + c可以跳过,但终究还是麻烦

解决方法

替换 brew 源,网上搜到的许多替换源方法无效是因为没替换homebrew-cask

1
2
3
4
5
6
7
8
9
10
11
12
cd "$(brew --repo)"
git remote set-url origin https://mirrors.ustc.edu.cn/brew.git

#替换homebrew-core.git
cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
git remote set-url origin https://mirrors.ustc.edu.cn/homebrew-core.git

#替换homebrew-cask.git
cd "$(brew --repo)/Library/Taps/homebrew/homebrew-cask"
git remote set-url origin https://mirrors.ustc.edu.cn/homebrew-cask.git

brew update

如果 update 后执行安装或者再次 update 有提示如下错误:

1
2
3
4
5
6
Error:
homebrew-core is a shallow clone.
homebrew-cask is a shallow clone.
To `brew update`, first run:
git -C /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core fetch --unshallow
git -C /usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask fetch --unshallow

按照提示分别执行命令即可

1
git -C /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core fetch --unshallow
1
git -C /usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask fetch --unshallow

其它一些坑

如何确定源是否有效

很简单,直接克隆一下,看速度是否OK

1
2
3
4
5
~/segon.cn/temp $ git clone https://mirrors.ustc.edu.cn/brew.git
Cloning into 'brew'...
remote: Enumerating objects: 175581, done.
remote: Total 175581 (delta 0), reused 0 (delta 0)
Receiving objects: 100% (175581/175581), 43.98 MiB | 9.21 MiB/s, done.
1
2
3
4
~/segon.cn/temp $ git clone https://mirrors.ustc.edu.cn/homebrew-core.git
Cloning into 'homebrew-core'...
remote: Enumerating objects: 882522, done.
Receiving objects: 77% (679542/882522), 294.25 MiB | 11.12 MiB/s
1
2
3
4
~/segon.cn/temp $ git clone https://mirrors.ustc.edu.cn/homebrew-cask.git                                                                                                            130 ↵
Cloning into 'homebrew-cask'...
remote: Enumerating objects: 592221, done.
Receiving objects: 22% (130289/592221), 32.99 MiB | 10.99 MiB/s

如何查看更新信息

1
brew update --verbose

还想看更多信息?

1
brew update --verbose --debug

update 卡住不动

  • ctrl + c 停止升级
  • 执行 brew doctor 看有没有可用的信息