? ??????Homebrew是一款自由而且開(kāi)放源碼的軟件包管理系統(tǒng),用以簡(jiǎn)化Mac OS系統(tǒng)的軟件安裝過(guò)程。
Homebrew以Ruby語(yǔ)言寫(xiě)成,針對(duì)于Mac OS X操作系統(tǒng)自帶Ruby的版本。默認(rèn)安裝在/usr/local,由一個(gè)核心git版本庫(kù)構(gòu)成,以使用戶能更新Homebrew。包管理器使用一種稱為“公式”(formula)的DSL腳本來(lái)管理依賴、下載源代碼及配置和編譯軟件,從源代碼中構(gòu)建軟件。稱為“瓶”(bottle)的二進(jìn)制包是用默認(rèn)選項(xiàng)預(yù)編譯好的公式。
Homebrew的安裝
Homebrew官方的安裝方法:?https://brew.sh/index_zh-cn.html
點(diǎn)擊鏈接復(fù)制頁(yè)面上的代碼,粘貼到你的Mac終端然后執(zhí)行即可。
###安裝失敗解決方法
curl: (7) Failed to connect to raw.githubusercontent.com port 443: Operation遇到這樣的失敗提示時(shí)可能是因?yàn)閕p被墻掉了,這時(shí)候可能會(huì)通過(guò)連接手機(jī)熱點(diǎn)解決掉這個(gè)問(wèn)題,也有可能通過(guò)代理的方法解決,這兩種就不在這里介紹了。我們介紹一種更為普適的,通過(guò)國(guó)內(nèi)鏡像的方式來(lái)進(jìn)行安裝。
1.獲取最新安裝腳本到本地
1.? ??cd~
2.? ??curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install >> brew_install
2.編輯brew_install文件
在終端輸入??vim brew_install? ?對(duì)文件進(jìn)行修改,打開(kāi)后應(yīng)該是下面的界面。(不是也沒(méi)關(guān)系,直接全部替換也可以的,我就是這么干的)
# This script installs to /usr/local only. To install elsewhere (which is
# unsupported) you can untar https://github.com/Homebrew/brew/tarball/master
# anywhere you like.
HOMEBREW_PREFIX = "/usr/local".freeze
HOMEBREW_REPOSITORY = "/usr/local/Homebrew".freeze
HOMEBREW_CORE_TAP = "/usr/local/Homebrew/Library/Taps/homebrew/homebrew-core".freeze
HOMEBREW_CACHE = "#{ENV["HOME"]}/Library/Caches/Homebrew".freeze
# BREW_REPO = "https://github.com/Homebrew/brew".freeze
BREW_REPO = "git://mirrors.ustc.edu.cn/brew.git".freeze
這里面在BREW_REPO = "https://github.com/Homebrew/brew".freeze這一行前面加上#注釋掉了
然后新增這一行? ?BREW_REPO = "git://mirrors.ustc.edu.cn/brew.git".freeze
3.腳本安裝
1.運(yùn)行腳本
/usr/bin/ruby brew_install
2.這時(shí)候腳本應(yīng)該會(huì)停留在??Cloning into '/usr/local/Homebrew/L... 這里。我們使用control/command+c??來(lái)停止進(jìn)程? (沒(méi)有停留可以不管)
3.接著依次運(yùn)行下列命令(如果過(guò)程中顯示homebrew-core已存在,前往文件夾將homebrew-core文件夾刪除將第三步再來(lái)一遍即可)
1)? ??cd "$(brew --repo)/Library/Taps/"
2)???mkdir homebrew
3)??cd homebrew
4)? ?git clone git://mirrors.ustc.edu.cn/homebrew-core.git
4.繼續(xù)執(zhí)行 /usr/bin/ruby ~/brew_install
5.當(dāng)看到? ??Installation successful!? ? ?時(shí)就安裝成功了。
4.替換Homebrew源
1.替換homebrew默認(rèn)源
1)? cd "$(brew --repo)"
2)? git remote set-url origin git://mirrors.ustc.edu.cn/brew.git?
2.替換Homebrew-core源
1) cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
2) git remote set-url origin git://mirrors.ustc.edu.cn/homebrew-core.git
5.brew更新(時(shí)間較久,賴心等待)
brew update
6.設(shè)置 bintray 鏡像
1? ? ?echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles' >> ~/.bash_profile
2.? ? source ~/.bash_profile
截止這里我們已經(jīng)成功的安裝了Homebrew
git更新(視需要而定)
1.輸入git --version查看當(dāng)前git版本
2.在終端輸入brew install git
3.當(dāng)出現(xiàn)Already downloaded和下載信息的時(shí)候說(shuō)明已經(jīng)安裝成功
4.接下來(lái)將git指向我們通過(guò)Homebrew安裝的git
brew link git --overwrite
6.重新打開(kāi)終端輸入git --version查看git版本,更新完成
結(jié)束語(yǔ):寫(xiě)本文是為了保留安裝方法,網(wǎng)上這類文章很多,試了很多才用這幾步安裝成功了。
推薦鏈接:http://www.itdecent.cn/p/22122a1d4474 ??