Homebrew - update に失敗する

「update」実行時に Error: homebrew-core is a shallow clone. が発生した場合の対処方法です。

brew update で表示されるエラー内容

$ brew update
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 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!

brew update

エラーが発生した発生した Homebrew のバージョン

$ brew --version
Homebrew 2.7.1
Homebrew/homebrew-core (git revision 0558c; last commit 2020-12-29)

brew --version

エラーの内容

Homebrew の更新ファイルは GitHub より取得しています。 今までは Git の shallow clone 機能(最新ファイルのみ取得する)を使用して更新データを取得していましたが、この方法は GitHub に負荷がかかるため、辞めるように要請がありました。shallow clone を使用しないように設定する必要がありますが、この設定を自動で行うとGitHub に負荷がかかるため、手動でコマンド実行してほしいという内容です。

解決方法

メッセージ内の git コマンドを実行します。 コマンド実行例
git -C /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core fetch --unshallow

git fetch fetch --unshallow

コマンド実行結果

$ git -C /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core fetch --unshallow
remote: Enumerating objects: 338391, done.
remote: Counting objects: 100% (338369/338369), done.
remote: Compressing objects: 100% (141567/141567), done.
remote: Total 330848 (delta 190905), reused 326415 (delta 186482), pack-reused
Receiving objects: 100% (330848/330848), 103.58 MiB | 333.00 KiB/s, done.
Resolving deltas: 100% (190905/190905), completed with 3569 local objects.
From https://github.com/Homebrew/homebrew-core
   0558cdb7f5..865fd38223  master     -> origin/master

fetch --unshallow(結果)

brew update の再実行 brew update

エラーが解消されない場合

設定変更後に brew update を実行すると、再び類似のエラーメッセージが表示されることがあります。その場合、同じ手順でメッセージ内のコマンドを実行し、shallow clone を無効化します。 (Homebrew は複数の Git リポジトリを使用しています。)

検証環境

関連ページ