Mac更新homebrew时卡住的解决办法
- 引起问题的原因
- brew命令安装软件跟这3个仓库地址有关
- 1、brew
- 2、homebrew-core
- 3、homebrew-bottles
- 4、若/bin/zsh,则输入
- 5、若/bin/bash,则输入
- 6、更新brew
引起问题的原因
知其然,还要知其所以然。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
就可以使用brew进行安装了