Mac OS如何brew update

Mac系統(tǒng)要更新點東西,還真難。我為了裝個GDB,就得先brew update下。結果發(fā)現(xiàn),這也不行。那也不行,自己上網(wǎng)查找和摸索了一天。終于裝好了,順便說下自己的系統(tǒng),是10.15.1版本的(目前最新版本)。遇到了一些問題,記錄下來,以備后續(xù)自己的使用之需。

1、執(zhí)行 brew install 命令長時間卡在 Updating Homebrew 或者brew update命令后卡很久。

這個怎么解決?網(wǎng)上基本上說了兩點,其實對于我本機器,卻要用到三點。

1)?替換 / 還原 brew.git 倉庫地址

# 替換成中科院的 brew.git 倉庫地址:

cd "$(brew --repo)"

git remote set-url origin?https://mirrors.ustc.edu.cn/brew.git

#=======================================================

# 還原為官方提供的 brew.git 倉庫地址

cd "$(brew --repo)"

git remote set-url origin https://github.com/Homebrew/brew.git

2)替換 / 還原 homebrew-core.git 倉庫地址

# 替換成中科院的 homebrew-core.git 倉庫地址:

cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"

git remote set-url originhttps://mirrors.ustc.edu.cn/homebrew-core.git

#=======================================================

# 還原為官方提供的 homebrew-core.git 倉庫地址

cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"

git remote set-url origin https://github.com/Homebrew/homebrew-core.git

3)替換 / 還原 homebrew-cask.git 倉庫地址

# 替換成中科院的 homebrew-cask.git 倉庫地址:

cd "$(brew --repo)" /Library/Taps/homebrew/homebrew-cask

git remote set-url origin https://mirrors.ustc.edu.cn/homebrew-cask.git

#=======================================================

# 還原為官方提供的 homebrew-cask.git 倉庫地址

cd "$(brew --repo)"/Library/Taps/homebrew/homebrew-cask

git remote set-url origin https://github.com/Homebrew/homebrew-cask

執(zhí)行完上面1)、2)、3)之后,我的電腦上,還碰到了RPC failed; curl 18 transfer closed with outstanding read data remaining 錯誤。于是有了下面2的操作。

2、解決緩存區(qū)溢出和下載速度慢

1)解決緩存區(qū)溢出:git clone時報RPC failed; curl 18 transfer closed with outstanding read data remaining 錯誤

git config http.postBuffer 524288000

執(zhí)行上面命令如果依舊clone失敗,考慮可能原因2:網(wǎng)絡下載速度緩慢

2)解決下載速度緩慢

git config --global http.lowSpeedLimit 0

git config --global http.lowSpeedTime 999999

如果依舊clone失敗,則首先淺層clone,然后更新遠程庫到本地

3)解決方法:

git clone --depth=1 http://gitlab.xxx.cn/yyy/zzz.git

git fetch --unshallow

最后,終端里輸入:

brew update && brew upgrade

就可以完美的解決了問題了。

參考

Homebrew 中文主頁

https://brew.sh/index_zh-cn.html

Homebrew Bottles 源使用幫助

http://mirrors.ustc.edu.cn/help/homebrew-bottles.html

Homebrew Cask 源使用幫助

http://mirrors.ustc.edu.cn/help/homebrew-cask.git.html

Homebrew Core 源使用幫助

http://mirrors.ustc.edu.cn/help/homebrew-core.git.html

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

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

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