freelancemate
cover

homebrewで怒られた【Error: homebrew-core is a shallow clone.】

更新日:2022年05月28日

brew installをしようとしたら、エラーが表示されました。

エラー詳細

Error: 
 homebrew-core is a shallow clone.
To `brew update`, first run:
 git -C /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core fetch --unshallow
This command may take a few minutes to run due to the large size of the repository.
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!

解決策

エラー文に記載されている通りですが、下記コマンドを実行してください。

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


少々時間がかかりますが、こちらでエラーは解消されます。
また、homebrew-caskを利用している場合は、追加で下記も必要です。

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

エラーの原因

エラーの原因はHomebrewの仕様変更です。2020年12月の仕様変更に伴い、swallow cloneではなく、cloneへの変更となりました。
この変更に合わせて、unswallow処理が必要となっています。