背景
在安裝 homebrew 時,由於眾所周知的原因,用官網的安裝方法很慢且容易中斷,想用國內的源進行安裝。
但是,網上大部分的方法都是
cd ~
curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install >> brew_install
之后再通過修改源,用 ruby 進行安裝,但是這個地址已經 🈚️ 了,通過這個方法寫入 brew_install 的內容為
#!/usr/bin/ruby
STDERR.print <<~EOS
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)"EOS
Kernel.exec "/bin/bash", "-c", '/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"'
Homebrew 科大源
通過原地址信息,我們將新地址更換為 https://raw.githubusercontent.com/Homebrew/install/master/install.sh
即進行一下操作:
cd ~
curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh >> brew_install
在終端用 open -e brew_install 或者在訪達中直接搜索整台Mac home_brew 雙擊打開。
#BREW_REPO="https://github.com/Homebrew/brew" #用第二行內容更換該行內容
BREW_REPO="git://mirrors.ustc.edu.cn/brew.git"
保存之后,在終端中輸入/bin/bash brew_install 進行快速安裝。
在安裝過程中會卡在
Cloning into '/usr/local/Homebrew/Library/Taps/homebrew/homebrew-core'...
於是可以直接 control c 結束,並直接使用 \(USTC\) 源進行更換。
mkdir -p /usr/local/Homebrew/Library/Taps/homebrew/
cd /usr/local/Homebrew/Library/Taps/homebrew
git clone https://mirrors.ustc.edu.cn/homebrew-core.git
配置完成后終端輸入brew help 顯示幫助信息則說明安裝成功,如果提示失敗請檢查 /usr/local/bin 下是否有 brew,有的話添加環境變量即可。
檢查操作
cd /usr/local/bin
ls | grep brew
