HomeBrew切换国内源

1. 修改源镜像

1.1 替换为清华大学镜像站
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

git -C "$(brew --repo homebrew/cask)" remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-cask.git

brew update

1.2 还原github(国内有时会出一些无法理解的bug)

git -C "$(brew --repo)" remote set-url origin https://github.com/Homebrew/brew.git

git -C "$(brew --repo homebrew/core)" remote set-url origin https://github.com/Homebrew/homebrew-core.git

git -C "$(brew --repo homebrew/cask)" remote set-url origin https://github.com/Homebrew/homebrew-cask.git

brew update

2.修改bottles

在shell配置文件(例如:.zshrc)加入以下环境变量

export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles

使配置文件生效

source ~/.zshrc

3.常见问题

碰到问题时,执行以下命令,然后按照命令提示修改

brew doctor
posted @ 2024-07-19 11:28  传VV说  阅读(1997)  评论(0)    收藏  举报