(一)brew 安裝方法一
- 進入brew官網(https://brew.sh/index_zh-cn.html)。
- 將圖中指令複製到終端中運行。
- 如果安裝過程中出現下載速度慢或下載安裝失敗,使用安裝方法二。
(二)brew 安裝方法二
- 複製上文指令中裏括號的部分,並在尾部加上 >> brew_install.sh,比如
curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh >> brew_install.sh
- 將上述指令複製到終端中運行。
- 用 vim 打開剛剛下載下來的 brew_install.sh。
vim brew_install.sh
- 將文件中的
BREW_REPO="https://github.com/Homebrew/brew"
改爲
BREW_REPO = "https://mirrors.ustc.edu.cn/brew.git"
CORE_TAP_REPO = "https://mirrors.ustc.edu.cn/homebrew-core.git"
- 按順序使用 ESC + : + wq,保存並退出。
- 運行下面指令,並按提示進行安裝,應該要按一次回車繼續並輸入密碼。
/bin/bash brew_install.sh
- 如果出現下面這種下載速度慢或者卡住的情況,把終端停掉,使用瀏覽器打開那個鏈接進行下載,比如這裏是 https://homebrew.bintray.com/bottles-portable-ruby/portable-ruby-2.6.3.mavericks.bottle.tar.gz,下載完成後將該文件放進 /Users/$你的用戶名/Library/Caches/Homebrew 中。
==> Downloading https://homebrew.bintray.com/bottles-portable-ruby/portable-ruby-2.6.3.mavericks.bottle.tar.gz
############### 21.6%
- 重新運行安裝指令。
/bin/bash brew_install.sh
- 如果安裝過程中卡在了 Clone 什麼的地方不動了,則停掉終端,運行下列指令。
git clone git://mirrors.ustc.edu.cn/homebrew-core.git/ /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core --depth=1
- 執行完上述指令,再重新運行安裝指令。
/bin/bash brew_install.sh
- 安裝完成。