11

1、mac 自带的 ruby 安装 homebrew

通常我们百度以后会用mac自带的ruby去安装homebrew,如下:

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

然后发现downloading很慢基本就10kb/s

2、亲测有用的解决方案

1. 先获取install文件,比如命名为brew_install:

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

2. 打开brew_install文件进行修改:

BREW_REPO = "https://github.com/Homebrew/brew".freeze

改为中国科大的源:

BREW_REPO = "https://mirrors.ustc.edu.cn/brew.git".freeze

3. 保存以后ruby执行brew_install

ruby brew_install

此时脚本会停在 :

==> Tapping homebrew/core Cloning into ‘/usr/local/Homebrew/Library/Taps/homebrew/homebrew-core’…

4. 把homebrew-core更换为中国科大镜像

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

5. 安装成功、更新、检测

brew update
brew doctor

湖人总冠军
514 声望721 粉丝

菜鸟与孤鹜齐飞