问题原因
因为我门安装brew时默认下载源都是github的下载源,国内访问会比较慢。
解决方案
将下载源替换为阿里云的下载源
替换内容
- brew.git仓库地址
- homebrew-core.git仓库地址
- homebrew-bottles
1、替换brew.git地址
将地址替换为阿里云的
cd "$(brew --repo)"
git remote set-url origin https://mirrors.aliyun.com/homebrew/brew.git
还原
cd "$(brew --repo)"
git remote set-url origin https://github.com/Homebrew/brew.git
2、替换homebrew-core地址
cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
git remote set-url origin https://mirrors.aliyun.com/homebrew/homebrew-core.git
还原为github地址
cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
git remote set-url origin https://github.com/Homebrew/homebrew-core.git
3、替换homebrew-bottles访问地址
将bash和zsh脚本都替换
echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.aliyun.com/homebrew/homebrew-bottles' >> ~/.zshrc
source ~/.zshrc
echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.aliyun.com/homebrew/homebrew-bottles' >> ~/.bash_profile
source ~/.bash_profile
还原方式:
vi ~/.bash_profile
vi ~/.zshrc
删除添加的变量HOMEBREW_BOTTLE_DOMAIN
最后
都替换完之后可以看到brew的config中的仓库地址都替换成了阿里云的地址
之后下载速度就会快好多了。