最近发现homebrew下载东西超级的慢,发现阿里的源很快,我这里分享一下我的修改过程:
# 替换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
# 替换homebrew-bottles:
echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.aliyun.com/homebrew/homebrew-bottles' >> ~/.zshrc
source ~/.zshrc
速度超级的快,看我的日志:
(base) ➜ Documents brew update --verbose
Checking if we need to fetch /usr/local/Homebrew...
Checking if we need to fetch /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core...
Fetching /usr/local/Homebrew...
Fetching /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core...
Updating /usr/local/Homebrew...
Branch 'master' set up to track remote branch 'master' from 'origin'.
Switched to and reset branch 'master'
Your branch is up to date with 'origin/master'.
Switched to and reset branch 'stable'
Current branch stable is up to date.
==> Downloading https://mirrors.aliyun.com/homebrew/homebrew-bottles/bottles-portable-ruby/portable-ruby-2.6.3_2.yosemite.bottle.tar.gz
Already downloaded: /Users/admin/Library/Caches/Homebrew/portable-ruby-2.6.3_2.yosemite.bottle.tar.gz
==> Pouring portable-ruby-2.6.3_2.yosemite.bottle.tar.gz
Already up-to-date.
类似地,还可以切换为中科院的镜像:
cd "$(brew --repo)"
git remote set-url origin https://mirrors.ustc.edu.cn/brew.git
cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
git remote set-url origin https://mirrors.ustc.edu.cn/homebrew-core.git
brew update
如果出现了下面的日志,也可以靠更换镜像解决哈:
Error: Failure while executing; `git clone https://github.com/Homebrew/homebrew-cask-versions
参考文献
[1].解决Homebrew下载更新极慢的问题. https://www.raydbg.com/2019/Homebrew-Update-Slow/
[2].MacOS brew安装报错问题. https://my.oschina.net/rubble/blog/3296556