Mac 搭配 homebrew 安装软件非常方便,然而homebrew托管在github,对国内用户来说不仅频频被墙,而且速度也不理想。
对于这个问题,我们可以通过更换 homebrew 数据源的方法解决,下面介绍更换为国内的数据源的方法。
中科大镜像比较稳定,而且速度不错。官方网站:http://mirrors.ustc.edu.cn/。搜索brew
,然后点击Help
即可查看用法:
参考地址: https://lug.ustc.edu.cn/wiki/mirrors/help/brew.git
# 替换brew.git:
cd "$(brew --repo)"
git remote set-url origin https://mirrors.ustc.edu.cn/brew.git
# 替换homebrew-core.git:
cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
git remote set-url origin https://mirrors.ustc.edu.cn/homebrew-core.git
brew update
参考地址:https://lug.ustc.edu.cn/wiki/mirrors/help/homebrew-bottles
对于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
参考: https://mirror.tuna.tsinghua.edu.cn/help/homebrew/
cd "$(brew --repo)"
git remote set-url origin https://github.com/Homebrew/brew.git
cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
git remote set-url origin https://github.com/Homebrew/homebrew-core.git
注释掉bash配置文件里的有关Homebrew Bottles即可恢复官方源。 重启bash或让bash重读配置文件。
执行brew更新命令
brew update
[1]
http://mirrors.ustc.edu.cn/: http://mirrors.ustc.edu.cn/[2]
https://lug.ustc.edu.cn/wiki/mirrors/help/brew.git: https://lug.ustc.edu.cn/wiki/mirrors/help/brew.git[3]
https://lug.ustc.edu.cn/wiki/mirrors/help/homebrew-bottles: https://lug.ustc.edu.cn/wiki/mirrors/help/homebrew-bottles[4]
https://mirror.tuna.tsinghua.edu.cn/help/homebrew/: https://mirror.tuna.tsinghua.edu.cn/help/homebrew/