在查找过程中发现,好多博客里的安装命令都是
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
结果点开https://raw.githubusercontent.com/Homebrew/install/master/install 发现内容为:
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)"
网址变为了https://raw.githubusercontent.com/Homebrew/install/master/install.sh
下载install.sh
把https://raw.githubusercontent.com/Homebrew/install/master/install.sh中的内容复制到本地目录作为shell脚本。
执行install.sh
1.如果卡在
Downloading Command Line Tools for Xcode……
不用安装Xcode,用xcode-select --install
命令安装Command Line Tools
继续执行install.sh
2.如果下载速度很慢只有几kb,更换shell脚本中的资源链接为国内的镜像。
找到如下代码
BREW_REPO = "https://github.com/Homebrew/brew"
更换为
BREW_REPO = "https://mirrors.ustc.edu.cn/brew.git"
就OK了,别的博客中有更换CORE_TAP_REPO,但由于最新版本的shell脚本中没有,就不进行更换。
重新执行./install.sh
3.之后又卡在了
==> Tapping homebrew/core
Cloning into '/usr/local/Homebrew/Library/Taps/homebrew/homebrew-core'...
执行如下命令:
cd "$(brew --repo)/Library/Taps/"
mkdir homebrew && cd homebrew
git clone git://mirrors.ustc.edu.cn/homebrew-core.git
再重新执行脚本./install.sh
看到
==> Installation successful!
就是安装成功了!
通过brew -v查看一下是否成功
记得加入环境变量