真解决brew-update卡主

5次阅读

共计 1031 个字符,预计需要花费 3 分钟才能阅读完成。

换了阿里源 brew update 依然卡主

使用了阿里的 homebrew 源:https://developer.aliyun.com/…

# 替换 brew.git:
cd "$(brew --repo)"
git remote set-url origin https://mirrors.aliyun.com/homebrew/brew.git
# 替换 homebrew-core.git:
cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
git remote set-url origin https://mirrors.aliyun.com/homebrew/homebrew-core.git
# 应用生效
brew update
# 替换 homebrew-bottles:
echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.aliyun.com/homebrew/homebrew-bottles' >> ~/.zshrc
source ~/.zshrc

使用 brew update -v 打印 log,发现卡在:

Checking if we need to fetch /usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask...

解决办法

阿里的镜像中没有homebrew-cask,使用中科大的源:

https://mirrors.ustc.edu.cn/h…

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

现在使用 brew update -v 终于通畅了

如果你仍然卡在别的地方,并且找不到国内镜像,可以尝试设置命令行代理:

export https_proxy=http://127.0.0.1:7890 http_proxy=http://127.0.0.1:7890 all_proxy=socks5://127.0.0.1:7891

原理

brew 的一些包信息维护在 github 上,brew update 除了主仓库,还要更新 brew taps(https://docs.brew.sh/Taps)。卡主的根本原因是 github 被墙,所以需要把这些仓库的 git 地址换成国内的镜像仓库地址。

正文完
 0