自动脚本:
/bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh)"
执行 brew install xxx
时,会遇到 brew update
卡住不动,按 control
+c
可取消更新 brew,接下来会自动执行 install xxx 操作。
当然,最好的解决办法还是切换到中科院的源:
See Also: https://mirrors.tuna.tsinghua.edu.cn/help/homebrew/
在切换成功后,可能会遇到的问题:
Error: homebrew-core is a shallow clone.
LibreSSL SSL_read: SSL_ERROR_SYSCALL, errno 54
fatal: read error: Connection reset by peer
最终解决步骤:
# 切换 homebrew 源
cd "$(brew --repo)"
git remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git
# 删除 homebrew-core
cd /usr/local/Homebrew/Library/Taps/homebrew
rm -rf homebrew-core
git gc
# 再使用中科院的源拉取 homebrew-core
git clone git://mirrors.ustc.edu.cn/homebrew-core.git
# homebrew-cask 按需拉取
# git clone git://mirrors.ustc.edu.cn/homebrew-cask.git
如果不确定换源是否成功,可使用 git remote -v
命令,查看当前源:
cd "$(brew --repo)"
git remote -v
cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
git remote -v