Mac解決brew慢的問題,添加國內源


在國內,使用brew極慢. 因為它需要訪問國外的一些服務器.

解決方法是使用國內的鏡像站.

如果是首次安裝:

curl https://raw.githubusercontent.com/Homebrew/install/master/install.sh  > install-brew.sh

然后,在下載的文件中, 修改BREW_REPO為:

BREW_REPO="https://mirrors.ustc.edu.cn/brew.git"

最后, 運行:

HOMEBREW_CORE_GIT_REMOTE=https://mirrors.ustc.edu.cn/homebrew-core.git bash install-brew.sh

 如果是已經安裝了brew, 可以這樣替換鏡像站:

cd "$(brew --repo)"
git remote set-url origin https://mirrors.ustc.edu.cn/brew.git

echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles' >> ~/.bash_profile
source ~/.bash_profile

cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
git remote set-url origin https://mirrors.ustc.edu.cn/homebrew-core.git

替換后, 就可以正常使用brew了.


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM