用过Mac的人都知道,homebrew——最好用的Mac平台包管理器。
Tips:
一、brew 命令每次都先 update,很慢怎么办(二选一):
1、更换update源(我选):
# 替换 brew.git
cd '$(brew --repo)'
# 清华大学:
git remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git
# 替换homebrew-core.git:
cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
#清华大学
git remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git
# 替换homebrew-bottles:
echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles' >> ~/.bash_profile
source ~/.bash_profile
# 应用生效:
brew update --verbose
很快!
注意⚠️:好像阿里镜像不包含 brew cask,没试过
注意⚠️:尽管替换了国内源,有些包还是找不到的,具体哪些找不到,可以直接访问 https://mirrors.tuna.tsinghua.edu.cn 上搜索查看。这时候就会再去 https://homebrew.bintray.com/ 上查找,而我这边不开代理的结果就是 403 Forbidden
注意⚠️:清华源包不全,很容易报403的错误,替换阿里源比较好
2、直接禁止 brew 自动更新:
# ~/.bash_profile 中加入:
export HOMEBREW_NO_AUTO_UPDATE=true
以后要更新主动 brew update