HomeBrew全新安裝搜索不到庫

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è)。

      1. 僅設(shè)置http和https代理(只對(duì)當(dāng)前終端有效)
    export http_proxy=http://proxyAddress:port
    export https_proxy=http://proxyAddress:port
    
      1. 僅設(shè)置socks5代理(只對(duì)當(dāng)前終端有效,代理地址假設(shè)為socks5://127.0.0.1:1080)
    export ALL_PROXY=socks5://127.0.0.1:1080
    
      1. 長(zhǎng)期設(shè)置需要將上述命令加入bash profile
      1. 通過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.

完成。

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容