1. 安裝
互聯(lián)網(wǎng)用戶復(fù)制這段到終端運(yùn)行即可安裝:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"-
對(duì)于局域網(wǎng)用戶,首先 macOS 默認(rèn)情況下終端是不走代理的,所以掛了梯子也不行,需要先對(duì)終端配置代理,參考SimonLiu009老師的文字,其實(shí)就是在
~/.zshrc(根據(jù)所用終端不同)文件下增加這行代碼,添加完會(huì)在新開終端中生效,沒有這個(gè)文件可以直接新建一個(gè)。- 僅設(shè)置http和https代理(只對(duì)當(dāng)前終端有效)
export http_proxy=http://proxyAddress:port export https_proxy=http://proxyAddress:port- 僅設(shè)置socks5代理(只對(duì)當(dāng)前終端有效,代理地址假設(shè)為socks5://127.0.0.1:1080)
export ALL_PROXY=socks5://127.0.0.1:1080- 長(zhǎng)期設(shè)置需要將上述命令加入bash profile
- 通過alias來快速切換
alias setproxy="export ALL_PROXY=socks5://127.0.0.1:1080" alias unsetproxy="unset ALL_PROXY" alias ip="curl -i http://ip.cn"
2. 配置正確的庫
這時(shí)候安裝一些不常見的庫會(huì)出現(xiàn)No formulae found in taps.的報(bào)錯(cuò)
運(yùn)行 brew doctor 發(fā)現(xiàn)默認(rèn)安裝的homebrew-coregit 地址不對(duì)
Warning: Suspicious https://github.com/Homebrew/homebrew-core git origin remote found.
The current git origin is:
https://github.com/Homebrew/brew
With a non-standard origin, Homebrew won't update properly.
You can solve this by setting the origin remote:
git -C "/usr/local/Homebrew/Library/Taps/homebrew/homebrew-core" remote set-url origin https://github.com/Homebrew/homebrew-core
按照提示輸入上述命令,結(jié)果
Error: Fetching /usr/local/Homebrew failed!
/usr/local/Homebrew/Library/Homebrew/brew.sh: line 109: /usr/local/bin/brew: No such file or directory
發(fā)現(xiàn) brew 命令不起作用了
下面嘗試進(jìn)入文件夾,強(qiáng)行更新homebrew-core文件夾
cd /usr/local/Homebrew/Library/Taps/homebrew/
rm -rf homebrew-core
git clone https://github.com/Homebrew/homebrew-core.git
brew 命令還是不行,一番查找發(fā)現(xiàn)是整個(gè)bin文件夾都沒有了,一般來說這是啟動(dòng)文件所在的文件夾,安裝的時(shí)候會(huì)釋放,于是想到重裝。
重新執(zhí)行/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)",文件校驗(yàn)通過,沒有重新下載,很快提示安裝完成。
嘗試brew doctor 顯示Your system is ready to brew.
完成。