Mac OS 10 安裝 Homebrew (由清華鏡像站)

v2-8f1ea66d5742981916b04879ebd0325c_1200x500.jpg

什么是Homebrew?

簡(jiǎn)單來(lái)說(shuō)就是一個(gè)macOS(或Linux)的包管理器,可以用它來(lái)安裝你需要的軟件,方便卸載跟升級(jí)。

安裝Homebrew

  1. 由官網(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)"
  1. 如安裝中出現(xiàn)問(wèn)題,將https://raw.githubusercontent.com/Homebrew/install/master/install中內(nèi)容另存為brew_shell 文件。

  2. 將brew_shell 中前幾行的一個(gè)變量做如下替換。

#BREW_REPO = "https://github.com/Homebrew/brew".freeze

BREW_REPO = "git://mirrors.ustc.edu.cn/brew.git".freeze
  1. 用如下命令安裝(~要用保存brew_shell的路徑替換)。
/usr/bin/ruby ~/brew_install
  1. 在安裝到如下時(shí),關(guān)閉命令行!
==> Tapping homebrew/core

Cloning into '/usr/local/Homebrew/Library/Taps/homebrew/homebrew-core'...
  1. 重新打開(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
  1. 替換homebrew默認(rèn)源。
cd "$(brew --repo)"

git remote set-url origin git://mirrors.ustc.edu.cn/brew.git
  1. 替換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
  1. 設(shè)置 bintray鏡像。
echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles' >> ~/.bash_profile

source ~/.bash_profile
  1. 運(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

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書(shū)系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容