在网上查找一番资料后发现各家说法都是改下.git仓库的镜像地址,但是改完之后发现并不太管用,瞎折腾了一番,总结一下解决方案

1.首先还是需要替换下镜像,毕竟墙还是会导致比较慢的问题,改了比不改好,当然也可以改回去

以阿里巴巴镜像为例

# 替换成阿里巴巴的 brew.git 仓库地址:
cd "$(brew --repo)"
git remote set-url origin https://mirrors.aliyun.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



if [ $SHELL = "/bin/bash" ] #如果你的是bash
then 
# 替换 homebrew-bottles 访问 URL:
echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.aliyun.com/homebrew/homebrew-bottles' >> ~/.bash_profile
source ~/.bash_profile
elif [ $SHELL = "/bin/zsh" ]
#如果用的shell 是zsh的话
then
# 替换成阿里巴巴的 homebrew-bottles 访问地址:
echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.aliyun.com/homebrew/homebrew-bottles' >> ~/.zshrc
source ~/.zshrc

fi

还原镜像配置


# 还原为官方提供的 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://github.com/Homebrew/homebrew-core.git


#删除环境变量
#如果是bash
# 还原为官方提供的 homebrew-bottles 访问地址
vi ~/.bash_profile
# 然后,删除 HOMEBREW_BOTTLE_DOMAIN 这一行配置
source ~/.bash_profile

#如果是zsh的话
# 还原为官方提供的 homebrew-bottles 访问地址
vi ~/.zshrc
# 然后,删除 HOMEBREW_BOTTLE_DOMAIN 这一行配置
source ~/.zshrc

执行了上述命令后,再执行

brew update

如果是正常运行的话,可以不用往下看了

如果还是不行的话,

brew doctor

#输出如下的错误信息
/usr/local/Homebrew/Library/Homebrew/global.rb:12:in `require': cannot load such file -- active_support/core_ext/object/blank (LoadError)
	from /usr/local/Homebrew/Library/Homebrew/global.rb:12:in `<top (required)>'
	from /usr/local/Homebrew/Library/Homebrew/brew.rb:23:in `require_relative'
	from /usr/local/Homebrew/Library/Homebrew/brew.rb:23:in `<main>'

看起来还是有问题,然后我们执行下

brew update-reset

然后再 brew update ,搞定。

有问题欢迎评论区交流~