關(guān)于Homebrew
由于涉及到Homebrew,這里也簡單記錄下使用過程中碰到到問題。目前國內(nèi)的使用環(huán)境,本來一些簡單的安裝也變得格外困難。
電腦之前也安裝過Homebrew,但可能由于用戶名改了或者是一些環(huán)境變量的問題。導(dǎo)致brew update的時候一直沒反應(yīng),使用brew doctor還出現(xiàn)了無權(quán)限寫入/usr/local。網(wǎng)上查閱了一下資料,可能是由于Mac OS權(quán)限機(jī)制的改動,作些修改就可以。但有一個更簡單的解決方法就是重裝Homebrew。
卸載
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/uninstall)"
安裝
如果可以通過運(yùn)行下面的代碼完成安裝,請?zhí)^安裝的步驟。
curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install
由于官方安裝會出現(xiàn)連不上的問題,因此我們需要把安裝指令修改一下,運(yùn)行
curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install >> brew_instal
會在終端所在目錄下生成一個brew_install的腳本,對它進(jìn)行編輯,把BREW_REPO和CORE_TAP_REPO(若存在)修改為國內(nèi)清華鏡像源。
BREW_REPO = "https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git".freeze
CORE_TAP_REPO = "https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git".freeze
運(yùn)行brew_install
/usr/bin/ruby ./brew_install
如果出現(xiàn)下面對代碼,可以不用等待,直接進(jìn)行下一步操作。
==> Tapping homebrew/core
Cloning into '/usr/local/Homebrew/Library/Taps/homebrew/homebrew-core'...
把homebrew repo切換為清華鏡像
cd "$(brew --repo)"
git remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git
cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
git remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git
如果提示不存在homebrew-core目錄,可以mkdir直接創(chuàng)建。
最后使用brew update應(yīng)該可以顯示homebrew已經(jīng)成功安裝。