Updating Homebrew卡住解决方案

7,044 阅读1分钟

最近使用Homebrew安装软件的时候经常卡在Updating Homebrew,于是寻找了下解决方案,作为记录。

关闭自动更新

在.zshrc文件中加入下方命令:

export HOMEBREW_NO_AUTO_UPDATE=true

如果是bash请加在.bash_profile文件中。

替换镜像源加速

我们平时执行brew命令安装软件的时候,跟这三个仓库有关:

1.brew.git
2.homebrew-core.git
3.homebrew-bottles

使用阿里的Homebrew镜像源代替可以进行加速

替换brew.git

cd "$(brew --repo)"
git remote set-url origin https://mirrors.aliyun.com/homebrew/brew.git

还原:

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

替换homebrew-core.git

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

还原:

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

替换homebrew-bottles访问地址

echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.aliyun.com/homebrew/homebrew-bottles' >> ~/.zshrc
source ~/.zshrc

还原的话就是删除HOMEBREW_BOTTLE_DOMAIN,上面的是zsh的命令,如果是bash的话请写在.bash_profile文件中。

参考文章:Homebrew长时间停在Updating Homebrew 这个步骤