Homebrew

更換國內源

主倉庫配置

cd $(brew --repo) && git remote -v
origin https://github.com/Homebrew/brew.git (fetch)
origin https://github.com/Homebrew/brew.git (push)

核心倉庫配置

cd $(brew --repo homebrew/core) && git remote -v
origin https://github.com/Homebrew/homebrew-core.git (fetch)
origin https://github.com/Homebrew/homebrew-core.git (push)

阿里雲鏡像

git -C "$(brew --repo)" remote set-url origin https://mirrors.aliyun.com/homebrew/brew.git
git -C "$(brew --repo homebrew/core)" remote set-url origin https://mirrors.aliyun.com/homebrew/homebrew-core.git
export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.aliyun.com/homebrew/homebrew-bottles

中科大鏡像

git -C "$(brew --repo)" remote set-url origin https://mirrors.ustc.edu.cn/brew.git
git -C "$(brew --repo homebrew/core)" remote set-url origin https://mirrors.ustc.edu.cn/homebrew-core.git
export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles

清華大學鏡像

git -C "$(brew --repo)" remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git
git -C "$(brew --repo homebrew/core)" remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git
export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles

驗證源配置

完成更換源操作後,可以執行以下命令驗證源配置是否成功。

brew update
brew config | grep -E 'ORIGIN|BOTTLE'

通過 brew config 命令,你可以檢查當前使用嘅倉庫源同 Bottle 源。

常見報錯

如果報 homebrew/core 目錄唔存在,可以使用以下命令檢查。

brew tap

如果冇輸出 homebrew/core,可以使用以下命令強制安裝。

brew tap --force homebrew/core