mac 上安装homebrew

背景

由于国外镜像不FQ的安装的话基本就会被qiang,所以按照官网的方式去安装会有error: RPC failed的错误;

  • 可以将安装的文件下载到本地,通过修改国内源去安装;
  • Homebrew是一个包管理器,用于在Mac上安装一些OSX上没有的UNIX工具(比如wget)

安装步骤

下载源到本地

curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install >> brew_install
若遇到错误
curl: (35) LibreSSL SSL_connect: SSL_ERROR_SYSCALL in connection to storage.googleapis.com:443
  • 输入命令移除代理后再安装即可
git config --global --unset http.proxy

修改镜像源

将

BREW_REPO = "https://github.com/Homebrew/brew".freeze
修改为(如果没有找到的CORE_TAP_REPO的话直接复制)

BREW_REPO = "https://mirrors.ustc.edu.cn/brew.git".freeze
CORE_TAP_REPO = "https://mirrors.ustc.edu.cn/homebrew-core.git".freeze

通过脚本安装brew

#直接在控制台输入

/usr/bin/ruby brew_install
  • 这里用的是中科院的源,可能会出现
fatal: early EOF
fatal: index-pack failed
Error: Failure while executing; `git clone https://github.com/Homebrew/homebrew-core /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core --depth=1` exited with 128.
Error: Failure while executing; `/usr/local/bin/brew tap homebrew/core` exited with 1.
Failed during: /usr/local/bin/brew update --force
  • 需要执行git clone git://mirrors.ustc.edu.cn/homebrew-core.git/ /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core --depth=1

homebrew-core的镜像地址也设为中科院的国内镜像

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

// 更新
brew update

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值