? ??????Homebrew是一款自由而且開放源碼的軟件包管理系統(tǒng)糙麦,用以簡化Mac OS系統(tǒng)的軟件安裝過程皆刺。
Homebrew以Ruby語言寫成,針對于Mac OS X操作系統(tǒng)自帶Ruby的版本。默認安裝在/usr/local脆霎,由一個核心git版本庫構(gòu)成,以使用戶能更新Homebrew狈惫。包管理器使用一種稱為“公式”(formula)的DSL腳本來管理依賴睛蛛、下載源代碼及配置和編譯軟件,從源代碼中構(gòu)建軟件胧谈。稱為“瓶”(bottle)的二進制包是用默認選項預編譯好的公式忆肾。
Homebrew的安裝
Homebrew官方的安裝方法:?https://brew.sh/index_zh-cn.html
點擊鏈接復制頁面上的代碼,粘貼到你的Mac終端然后執(zhí)行即可菱肖。
###安裝失敗解決方法
curl: (7) Failed to connect to raw.githubusercontent.com port 443: Operation遇到這樣的失敗提示時可能是因為ip被墻掉了客冈,這時候可能會通過連接手機熱點解決掉這個問題,也有可能通過代理的方法解決稳强,這兩種就不在這里介紹了场仲。我們介紹一種更為普適的,通過國內(nèi)鏡像的方式來進行安裝退疫。
1.獲取最新安裝腳本到本地
1.? ??cd~
2.? ??curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install >> brew_install
2.編輯brew_install文件
在終端輸入??vim brew_install? ?對文件進行修改渠缕,打開后應該是下面的界面。(不是也沒關(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.運行腳本
/usr/bin/ruby brew_install
2.這時候腳本應該會停留在??Cloning into '/usr/local/Homebrew/L... 這里。我們使用control/command+c??來停止進程? (沒有停留可以不管)
3.接著依次運行下列命令(如果過程中顯示homebrew-core已存在,前往文件夾將homebrew-core文件夾刪除將第三步再來一遍即可)
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.當看到? ??Installation successful!? ? ?時就安裝成功了燕差。
4.替換Homebrew源
1.替換homebrew默認源
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更新(時間較久遭笋,賴心等待)
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查看當前git版本
2.在終端輸入brew install git
3.當出現(xiàn)Already downloaded和下載信息的時候說明已經(jīng)安裝成功
4.接下來將git指向我們通過Homebrew安裝的git
brew link git --overwrite
6.重新打開終端輸入git --version查看git版本,更新完成
結(jié)束語:寫本文是為了保留安裝方法谁不,網(wǎng)上這類文章很多坐梯,試了很多才用這幾步安裝成功了。
推薦鏈接:http://www.reibang.com/p/22122a1d4474 ??