Mac更新homebrew时卡住的解决办法

引起问题的原因

知其然,还要知其所以然。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进行安装了

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值