在macOS上使用Homebrew的怔锌,對(duì)官方源的速度都深有體會(huì)依疼,慢的能讓你感動(dòng)的痛哭流涕,哪怕是一個(gè)極其微小的軟件都要半個(gè)多小時(shí)蔗喂。
更新 git repo 源
# 替換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
# 應(yīng)用刷新
$ brew update
更新 bottles 源
# 使用zsh
$ echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.aliyun.com/homebrew/homebrew-bottles' >> ~/.zshrc
$ source ~/.zshrc
# 使用bash
$ echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.aliyun.com/homebrew/homebrew-bottles' >> ~/.bash_profile
$ source ~/.bash_profile
我用的是阿里云的源罕容,速度還比較不錯(cuò)(也可以自行搜索其他的源:清華备恤、騰訊、七牛...)
恢復(fù)出廠設(shè)置
某些時(shí)候锦秒,可能需要恢復(fù)默認(rèn)的配置
# 替換brew.git
$ cd "$(brew --repo)"
$ git remote set-url origin https://github.com/Homebrew/brew.git
# 替換homebrew-core.git
$ cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
$ git remote set-url origin https://github.com/Homebrew/homebrew-core.git
# 應(yīng)用刷新
$ brew update
從 ~/.zshrc 或 ~/.bash_profile 中刪除 HOMEBREW_BOTTLE_DOMAIN 環(huán)境變量露泊,然后應(yīng)用刷新
# zsh
$ source ~/.zshrc
# bash
$ source ~/.bash_profile
相關(guān)鏈接:Homebrew