macOS 安装 homebrew 国内源

背景

在安装 homebrew 时,由于众所周知的原因,用官网的安装方法很慢且容易中断,想用国内的源进行安装。

但是,网上大部分的方法都是

cd ~
curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install >> brew_install

之后再通过修改源,用 ruby 进行安装,但是这个地址已经 🈚️ 了,通过这个方法写入 brew_install 的内容为

#!/usr/bin/ruby

STDERR.print <<~EOS
Warning: The Ruby Homebrew installer is now deprecated and has been rewritten in
Bash. Please migrate to the following command:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"

EOS

Kernel.exec "/bin/bash", "-c", '/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"'

Homebrew 科大源

通过原地址信息,我们将新地址更换为 https://raw.githubusercontent.com/Homebrew/install/master/install.sh

即进行一下操作:

cd ~
curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh >> brew_install

在终端用 open -e brew_install 或者在访达中直接搜索整台Mac home_brew 双击打开。

#BREW_REPO="https://github.com/Homebrew/brew" #用第二行内容更换该行内容
BREW_REPO="git://mirrors.ustc.edu.cn/brew.git"

保存之后,在终端中输入/bin/bash brew_install 进行快速安装。

在安装过程中会卡在

Cloning into '/usr/local/Homebrew/Library/Taps/homebrew/homebrew-core'...

于是可以直接 control c 结束,并直接使用 \(USTC\) 源进行更换。

mkdir -p /usr/local/Homebrew/Library/Taps/homebrew/
cd /usr/local/Homebrew/Library/Taps/homebrew
git clone https://mirrors.ustc.edu.cn/homebrew-core.git

配置完成后终端输入brew help 显示帮助信息则说明安装成功,如果提示失败请检查 /usr/local/bin 下是否有 brew,有的话添加环境变量即可。

检查操作

cd /usr/local/bin
ls | grep brew
posted @ 2020-05-31 22:01  Acerkoo  阅读(2007)  评论(0编辑  收藏  举报