国内用官方方式安装Homebrew的时候总是会遇到各种问题。但其实手动安装非常简单快速(需要系统中有git),依次在终端中执行以下命令(x86):
cd /usr/local/
git clone https://github.com/Homebrew/brew.git --depth 1
sudo ln -s /usr/local/brew/bin/brew /usr/local/bin/brew
sudo mkdir -p /usr/local/brew/Library/Taps/homebrew
cd /usr/local/brew/Library/Taps/homebrew
git clone https://github.com/Homebrew/homebrew-core.git --depth 1
git clone https://github.com/Homebrew/homebrew-cask.git --depth 1
sudo chown -R $(whoami) /usr/local/brew
sudo chown -R $(whoami) /usr/local/Cellar
sudo chown -R $(whoami) /usr/local/var/homebrew
上述命令中如果提示某文件已存在,先用rm -rf
删除即可
对于arm处理器,只需把上面的/usr/local/
换成/opt/
就行
这时就安装好了,可以查看版本试试:
brew -v