mac安装homebrew

官网下载安装脚本

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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值