MacBook安装homebrew遇到问题的解决方法

2020-03-14  本文已影响0人  码农_会写诗

访问https://brew.sh/index_zh-cn,可以看到官方的安装方法是将以下命令粘贴到终端执行。

粘贴到终端:/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"

但是,由于GFW的存在,按照官方的方式去安装可能会碰到Failed to connect to raw.githubusercontent.com port 443: Connection refused的错误,或者安装过程中会碰到error: RPC failed的错误。

替代方案是通过以下命令将安装脚本下载到本地执行。

终端输入:curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh >> brew_install

本地执行之前需要将BREW_REPO = "https://github.com/Homebrew/brew”替换成以下内容。

BREW_REPO="https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git”

之后,通过以下命令执行本地脚本。

终端输入:bashbrew_install

如果碰到Error: Failure while executing; git clone的错误,执行以下脚本解决。

终端输入: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

brew update

最后,设置二进制包镜像

echo'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles'>>~/.bash_profilesource~/.bash_profile

ok 现在就可以使用啦

上一篇 下一篇

猜你喜欢

热点阅读