mac默认的homebrew源托管与github,其在国内不好访问。所以很多同学发现update brew时候常常失败。
解决方法就是替换brew的源。实际操作中,有4个源需要替换。(这里用的是中科大的源,其他也有不错的,比如清华的,大家可以自行搜索)
1、替换homebrew默认源。
默认是https://github.com/Homebrew/brew.git,替换:
cd "$(brew --repo)"
git remote set-url origin https://mirrors.ustc.edu.cn/brew.git
2、替换homebrew-core默认源
默认是https://github.com/Homebrew/homebrew-core.git, 替换:
cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
git remote set-url origin https://mirrors.ustc.edu.cn/homebrew-core.git
3、替换homebrew-cask默认源
默认是https://github.com/Homebrew/homebrew-cask,替换
cd /usr/local/Homebrew/Library/Taps/caskroom/homebrew-cask
git remote set-url origin git://mirrors.ustc.edu.cn/homebrew-cask.git