引起问题的原因
知其然,还要知其所以然。brew的更新仓库地址为:https://github.com/Homebrew/brew.git
看了地址,想想就知道是被墙了。
brew命令安装软件跟这3个仓库地址有关
brew.git
homebrew-core
homebrew-bottles
最快的解决方式,使用国内的镜像仓库:
Mac终端中,输入
1、brew
cd “$(brew --repo)”
git remote set-url origin https://mirrors.aliyun.com/homebrew/brew.git
(还原:git remote set-url origin https://github.com/homebrew/brew.git)
2、homebrew-core
cd “$(brew --repo)/Library/Taps/homebrew/homebrew-core”
git remote set-url origin https://mirrors.aliyun.com/homebrew/homebrew-core.git
(还原:git remote set-url origin https://github.com/homebrew/homebrew-core.git)
3、homebrew-bottles
cd “$(brew --repo)/Library/Taps/homebrew/homebrew-core”
git remote set-url origin https://mirrors.aliyun.com/homebrew/homebrew-bottles.git
(还原:git remote set-url origin https://github.com/homebrew/homebrew-bottles.git)
输入:echo $SHELL
看输出是:/bin/zsh 或 /bin/bash
4、若/bin/zsh,则输入
echo ‘export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.aliyun.com/homebrew/homebrew-bottles’ >> ~/.zshrc
source ~/.zshrc
(还原:vi ~/.zshrc,删除 HOMEBREW_BOTTLE_DOMAIN 这一行配置)
5、若/bin/bash,则输入
HOMEBREW_BOTTLE_DOMAIN=https://mirrors.aliyun.com/homebrew/homebrew-bottles’ >> ~/.bash_profile
source ~/.bash_profile
(还原:vi ~/.bash_profile,删除 HOMEBREW_BOTTLE_DOMAIN 这一行配置)
6、更新brew
brew update
如有报错,执行:brew update-reset
再执行:brew update文章来源:https://www.toymoban.com/news/detail-655148.html
就可以使用brew进行安装了文章来源地址https://www.toymoban.com/news/detail-655148.html
到了这里,关于Mac更新homebrew时卡住的解决办法的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!