第一步:
安裝xcode村刨,可以在AppStore中查詢xcode進行安裝
第二步:
不能直接使用brew官網(wǎng)提供的在線安裝的命令
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
可能會出現(xiàn)如下報錯信息
Xcode-select: error: invalid developer directory ‘/Library/Developer/CommandLineTools’ Failed during: /usr/bin/sudo /usr/bin/xcode-select –switch /Library/Developer/CommandLineTools
原因是 Xcode-select
已經(jīng)在Xcode安裝的時候一并安裝好模蜡,但是路徑不是錯誤中顯的/Library/Developer/CommandLineTools
.
解決:
- 在終端上輸入
xcode-select -p
可知xcode-select的安裝路徑是/Applications/Xcode.app/Contents/Developer
,所以要改一下安裝的腳本命令 - 先將安裝brew的腳本文件下載到本地
curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh >> brew_install
- 修改這個
brew_install
的腳本文件猬膨,將其中的/Library/Developer/CommandLineTools
統(tǒng)統(tǒng)替換為/Applications/Xcode.app/Contents/Developer
- 可以使用vi打開
brew_install
,在命令模式中輸入命令%s/\/Library\/Developer\/CommandLineTools/\/Applications\/Xcode.app\/Contents\/Developer/g
第三步
更改腳本中的資源鏈接艾蓝,替換成中國科學技術大學的鏡像
就是把這兩句
BREW_REPO = “https://github.com/Homebrew/brew“.freeze
CORE_TAP_REPO = “https://github.com/Homebrew/homebrew-core“.freeze
更改為這兩句
BREW_REPO = “https://mirrors.ustc.edu.cn/brew.git “.freeze
CORE_TAP_REPO = “https://mirrors.ustc.edu.cn/homebrew-core.git“.freeze
當然如果這個鏡像有問題的話牵囤,可以換成別的
然后開始安裝
/usr/bin/ruby brew_install
看到如下輸出信息,表示安裝成功
第四步
- 替換homebrew源欣舵,執(zhí)行如下命令
cd "$(brew --repo)”
git remote set-url origin https://mirrors.ustc.edu.cn/brew.git
cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core”
git remote set-url origin https://mirrors.ustc.edu.cn/homebrew-core.git
- 更新brew(確認為最新版本)
brew update
- 設置 bintray鏡像
echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles' >> ~/.bash_profile
source ~/.bash_profile
第四步
安裝你想要的包擎鸠,例如docker
brew install docker
基本用法:
假定操作對象為 wget,請?zhí)鎿Q為自己需要的軟件包名
操作 命令 | |
---|---|
更新 Homebrew | brew update |
更新所有安裝過的軟件包 | brew upgrade |
更新指定的軟件包 | brew upgrade wget |
查找軟件包 | brew search wget |
安裝軟件包 | brew install wget |
卸載軟件包 | brew remove wget |
列出已安裝的軟件包 | brew list |
查看軟件包信息 | brew info wget |
列出軟件包的依賴關系 | brew deps wget |
列出可以更新的軟件包 | brew outdated |
Homebrew 中文主頁
https://brew.sh/index_zh-cn.html
Homebrew Bottles 源使用幫助
http://mirrors.ustc.edu.cn/help/homebrew-bottles.html
Homebrew Cask 源使用幫助
http://mirrors.ustc.edu.cn/help/homebrew-cask.git.html
Homebrew Core 源使用幫助
http://mirrors.ustc.edu.cn/help/homebrew-core.git.html