原因
brew update
实际上会从https://github.com/homebrew/brew更新代码。具体可以用brew update -v
查看进度就知道了。
既然资源访问太慢原因造成的,那就替换一下镜像就可以了
替换镜像
# brew 程序本身,Homebrew/Linuxbrew 相同
git -C "$(brew --repo)" remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git
# 以下针对 mac OS 系统上的 Homebrew
# brew
cd "$(brew --repo)" && git remote set-url origin https://mirrors.ustc.edu.cn/brew.git
# homebrew-core
cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core" && git remote set-url origin https://mirrors.ustc.edu.cn/homebrew-core.git
# homebrew-cask
cd "$(brew --repo)/Library/Taps/homebrew/homebrew-cask" && git remote set-url origin https://mirrors.ustc.edu.cn/homebrew-cask.git
# Homebrew Bottles (Homebrew 预编译二进制软件包)
```shell
对于 bash 用户:
echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles' >> ~/.bash_profile
source ~/.bash_profile
#对于 zsh 用户:
echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles' >> ~/.zshrc
source ~/.zshrc
更换后测试工作是否正常
brew update
参考:
1、[//www.greatytc.com/p/62f1b963baa6](//www.greatytc.com/p/62f1b963baa6)
2、[https://mirrors.tuna.tsinghua.edu.cn/help/homebrew/](https://mirrors.tuna.tsinghua.edu.cn/help/homebrew/)
3、[Homebrew Bottles 源使用帮助](http://mirrors.ustc.edu.cn/help/homebrew-bottles.html)