關(guān)于Homebrew
由于涉及到Homebrew,這里也簡(jiǎn)單記錄下使用過(guò)程中碰到到問(wèn)題。目前國(guó)內(nèi)的使用環(huán)境,本來(lái)一些簡(jiǎn)單的安裝也變得格外困難。
電腦之前也安裝過(guò)Homebrew,但可能由于用戶名改了或者是一些環(huán)境變量的問(wèn)題。導(dǎo)致brew update的時(shí)候一直沒(méi)反應(yīng),使用brew doctor還出現(xiàn)了無(wú)權(quán)限寫(xiě)入/usr/local。網(wǎng)上查閱了一下資料,可能是由于Mac OS權(quán)限機(jī)制的改動(dòng),作些修改就可以。但有一個(gè)更簡(jiǎn)單的解決方法就是重裝Homebrew。
卸載
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/uninstall)"
安裝
如果可以通過(guò)運(yùn)行下面的代碼完成安裝,請(qǐng)?zhí)^(guò)安裝的步驟。
curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install
由于官方安裝會(huì)出現(xiàn)連不上的問(wèn)題,因此我們需要把安裝指令修改一下,運(yùn)行
curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install >> brew_instal
會(huì)在終端所在目錄下生成一個(gè)brew_install的腳本,對(duì)它進(jìn)行編輯,把BREW_REPO和CORE_TAP_REPO(若存在)修改為國(guó)內(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)下面對(duì)代碼,可以不用等待,直接進(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)成功安裝。