我们如果使用brew
命令安装一些插件是,会卡在Updating Homebrew
:
那么该如何解决呢?有两种方式:
- 关闭提示(治标不治本)
- 替换镜像源
首先看看关闭提示的方式,直接在控制台输入命令:
vim ~/.bash_profile
并在最后一行增加:
export HOMEBREW_NO_AUTO_UPDATE=true
最后使配置生效:
source ~/.bash_profile
03 替换镜像源
3.1 替换为ustc源
cd "$(brew --repo)"
git remote set-url origin https://mirrors.ustc.edu.cn/brew.git
brew update
cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
git remote set-url origin https://mirrors.ustc.edu.cn/homebrew-core.git
brew update
我的本机操作成功了,如下图:
3.2 替换为coding源
cd "$(brew --repo)"
git remote set-url origin https://git.coding.net/homebrew/homebrew.git
brew update
3.3 替换为tsinghua源
cd "$(brew --repo)"
git remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/brew.git
cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
git remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew-core.git
brew update
04 恢复设置
如果以上设置都不行,则恢复默认设置:
cd "$(brew --repo)"
git remote set-url origin https://github.com/Homebrew/brew.git
cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
git remote set-url origin https://github.com/Homebrew/homebrew-core.git