homebrew-core/cask is a shallow clone

前言

最近在安裝 Homebrew 時會出現「homebrew-core is a shallow clone.」與「homebrew-cask is a shallow clone.」的錯誤訊息,所以這一篇紀錄一下如何解決。

事發

因為最近在弄東西,所以要用 Homebrew,當我輸入官方提示的安裝指令在終端機上:

1
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

安裝過程看起來是非常正常,但是接下來就會批噴一段錯誤訊息:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
HEAD is now at 514271010 Merge pull request #11556
Error:
homebrew-core is a shallow clone.
homebrew-cask is a shallow clone.
To `brew update`, first run:
git -C /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core fetch --unshallow
git -C /usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask fetch --unshallow
These commands may take a few minutes to run due to the large size of the repositories.
This restriction has been made on GitHub's request because updating shallow
clones is an extremely expensive operation due to the tree layout and traffic of
Homebrew/homebrew-core and Homebrew/homebrew-cask. We don't do this for you
automatically to avoid repeatedly performing an expensive unshallow operation in
CI systems (which should instead be fixed to not use shallow clones). Sorry for
the inconvenience!
Failed during: /usr/local/bin/brew update --force --quiet

簡單來講就是有一些安裝意外,所以你要輸入以下這兩段指令(請分開輸入,輸入完之後需要一點時間,所以請耐心等待。):

1
2
git -C /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core fetch --unshallow
git -C /usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask fetch --unshallow

我必須說這指令執行期間很久,我大約跑了五分鐘才跑完,所以輸入完之後好像卡住一樣,請耐心等待。

當然這個狀況並不會只發生在安裝 Homebrew,當你輸入 brew update 時也會有機會遇到,

另外如果你輸入 brew search [text] 卻出現 Error: Cask 'deeper' definition is invalid: invalid 'depends_on macos' value: unknown or unsupported macOS version: :mavericks,基本上可以先試著輸入 brew update 等它更新一下,接下來就可以正常使用了。

Liker 讚賞

這篇文章如果對你有幫助,你可以花 30 秒登入 LikeCoin 並點擊下方拍手按鈕(最多五下)免費支持與牡蠣鼓勵我。
或者你也可以考慮請我喝一杯咖啡

Google AD

撰寫一篇文章其實真的很花時間,如果你願意「關閉 Adblock (廣告阻擋器)」來支持我的話,我會非常感謝你 ヽ(・∀・)ノ