官网下载安装脚本
https://brew.sh/index_zh-cn官网下载安装命令,提取地址信息,直接浏览器打开后保持脚本为brew_install.rb,比如我下载的版本命令为:
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
我们截取https://raw.githubusercontent.com/Homebrew/install/master/install
用浏览器打开保存即可
替换文件中的仓库地址为中科院
BREW_REPO = “https://github.com/Homebrew/brew“.freeze
改为
BREW_REPO = “https://mirrors.ustc.edu.cn/brew.git “.freeze
执行安装脚本
ruby brew_install.rb
安装时会出错需要更换镜像
因为有些下载还是国外的,下不下来,安装会出现错误
error: RPC failed; curl 56 LibreSSL SSL_read: SSL_ERROR_SYSCALL, errno 54
fatal: the remote end hung up unexpectedly
fatal: early EOF
fatal: index-pack failed
我们更改地址为中科院镜像进行clone
git clone git://mirrors.ustc.edu.cn/homebrew-core.git/ /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core --depth=1
再改原远程仓库地址为中科院
cd "$(brew --repo)"
git remote set-url origin https://mirrors.ustc.edu.cn/brew.git
cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
git remote set-url origin https://mirrors.ustc.edu.cn/homebrew-core.git
cd "$(brew —repo)/Library/Taps/homebrew/homebrew-cask"
git remote set-url origin https://mirrors.ustc.edu.cn/homebrew-cask.git
我们再执行
brew update
最后用这个命令检查错误
Brew doctor
也可以查看配置
brew config
以上就可以完成安装了,如果还是感觉哪块操作很慢的话,就科学上网全局和PAC切着玩~
我们也可以把镜像还原
cd "$(brew --repo)"
git remote set-url origin https://github.com/Homebrew/brew.git
cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
git remote set-url origin https://github.com/Homebrew/homebrew-core.git
cd "$(brew --repo)/Library/Taps/homebrew/homebrew-cask"
git remote set-url origin https://github.com/Homebrew/homebrew-cask.git
brew update
https://www.cnblogs.com/jingxiaoniu/p/11123377.html