
v2-8f1ea66d5742981916b04879ebd0325c_1200x500.jpg
什么是Homebrew?
簡(jiǎn)單來(lái)說(shuō)就是一個(gè)macOS(或Linux)的包管理器,可以用它來(lái)安裝你需要的軟件,方便卸載跟升級(jí)。
安裝Homebrew
- 由官網(wǎng)(https://brew.sh/index_zh-cn.html)復(fù)制安裝命令,輸入到bash shell 中。
/usr/bin/ruby -e "$(curl -fsSLhttps://raw.githubusercontent.com/Homebrew/install/master/install)"
如安裝中出現(xiàn)問(wèn)題,將https://raw.githubusercontent.com/Homebrew/install/master/install中內(nèi)容另存為brew_shell 文件。
將brew_shell 中前幾行的一個(gè)變量做如下替換。
#BREW_REPO = "https://github.com/Homebrew/brew".freeze
BREW_REPO = "git://mirrors.ustc.edu.cn/brew.git".freeze
- 用如下命令安裝(~要用保存brew_shell的路徑替換)。
/usr/bin/ruby ~/brew_install
- 在安裝到如下時(shí),關(guān)閉命令行!
==> Tapping homebrew/core
Cloning into '/usr/local/Homebrew/Library/Taps/homebrew/homebrew-core'...
- 重新打開(kāi)命令行,用清華的鏡像站進(jìn)行clone。
cd /usr/local/Homebrew/Library/Taps/homebrew
git clone https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git
- 替換homebrew默認(rèn)源。
cd "$(brew --repo)"
git remote set-url origin git://mirrors.ustc.edu.cn/brew.git
- 替換homebrew-core默認(rèn)源。
cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
git remote set-url origin git://mirrors.ustc.edu.cn/homebrew-core.git
- 設(shè)置 bintray鏡像。
echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles' >> ~/.bash_profile
source ~/.bash_profile
- 運(yùn)行
brew doctor,可發(fā)現(xiàn)git origin已經(jīng)成功替換。以后可以運(yùn)行brew update進(jìn)行更新。
附錄:清華鏡像站 https://mirrors.tuna.tsinghua.edu.cn/help/homebrew-bottles/
參考資料:
https://zhuanlan.zhihu.com/p/93092044
https://zhuanlan.zhihu.com/p/59805070