Homebrew更換國內映象源
阿新 • • 發佈:2021-08-11
Homebrew官方的源一般下載包之類的速度會很慢,通常用國內的映象源來代替,提高效率。
Homebrew主要由四部分組成:
名稱 | 說明 |
---|---|
brew | Homebrew原始碼倉庫 |
homebrew-core | Homebrew核心軟體倉庫 |
homebrew-bottles | Homebrew預編譯二進位制軟體包 |
homebrew-cask | MacOS客戶端應用 |
目前國內映象源主要有:中科大映象、阿里映象、清華映象
首先檢視本地的映象源地址,命令列輸入如下內容:
檢視brew.git當前源
cd "$(brew --repo)" && git remote -v
檢視homebrew-core.git當前源。
cd "$(brew --repo homebrew/core)" && git remote -v
若輸出以下內容,則不是本地映象源,可以更換
切換Homebrew映象源為中科大映象源
替換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
替換homebrew-cask.git:
cd "$(brew --repo)/Library/Taps/homebrew/homebrew-cask" && git remote set-url origin https://mirrors.ustc.edu.cn/homebrew-cask.git
zsh 替換homebrew-bottles映象,Mac OS在10.15系統開始,預設的shell都換成了zsh
echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles' >> ~/.zshrc
修改使其立即生效
source ~/.zshrc
bash 替換homebrew-bottles映象
echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles' >> ~/.bash_profile
修改使其立即生效
source ~/.bash_profile
重新整理源
brew update
檢查,結果如下圖,更改成功!
參考文章連結: Homebrew更換國內映象源(中科大、阿里、清華)