訪問https://brew.sh/index_zh-cn,可以看到官方的安裝方法是將以下命令粘貼到終端執(zhí)行冻记。
粘貼到終端:/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的錯誤炼幔。
替代方案是通過以下命令將安裝腳本下載到本地執(zhí)行鸽心。
終端輸入:curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh >> brew_install
本地執(zhí)行之前需要將BREW_REPO = "https://github.com/Homebrew/brew”替換成以下內(nèi)容滚局。
BREW_REPO="https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git”
之后,通過以下命令執(zhí)行本地腳本顽频。
終端輸入:bashbrew_install
如果碰到Error: Failure while executing; git clone的錯誤藤肢,執(zhí)行以下腳本解決。
終端輸入:git clone git://mirrors.ustc.edu.cn/homebrew-core.git/ /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core --depth=1(我在安裝過程中沒遇到糯景,如不能解決嘁圈,請找度娘解決)
安裝完成后,還要通過以下命令將homebrew-core的鏡像地址也設(shè)置為國內(nèi)鏡像蟀淮。
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
最后最住,設(shè)置二進(jìn)制包鏡像
echo'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles'>>~/.bash_profilesource~/.bash_profile
ok 現(xiàn)在就可以使用啦