注目キーワード
  1. 技術
  2. 広告
  3. IDFA
  4. PHP
  5. WordPress

Homebrew を使ったら、Error: homebrew-core is a shallow clone. と出てきたときの対処法

brew 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 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!
Error: libbluray: Calling depends_on :java is disabled! Use "depends_on "openjdk@11", "depends_on "openjdk@8" or "depends_on "openjdk" instead.
Please report this issue to the homebrew/core tap (not Homebrew/brew or Homebrew/core), or even better, submit a PR to fix it:
  /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/libbluray.rb:30

エラー原因

homebrew は、shallow cloneという最新のコミット履歴のみを取得して、高速にcloneできる仕組みを使っていました。ですが、2020年12月頃に、shallow cloneではなく、通常のcloneを使うように処理変更が行なわれました。恐らく、shallow cloneの更新は、通常よりも処理が重くなってしまうため、このような変更があったのかと推測しています。

homebrew-core is a shallow clone の対応方法

エラー文を見ると、

To `brew update`, first run:
  git -C /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core fetch --unshallow

brew update をするために、homebrew-core fetch –unshallow を最初に実行してくださいと書かれていますので、記載されているコマンドを実行して、homebrewの更新を行ないます。

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

remote: Enumerating objects: 673493, done.
remote: Counting objects: 100% (673445/673445), done.
remote: Compressing objects: 100% (229948/229948), done.
remote: Total 664054 (delta 439891), reused 655254 (delta 431240), pack-reused 0
Receiving objects: 100% (664054/664054), 255.12 MiB | 4.93 MiB/s, done.
Resolving deltas: 100% (439891/439891), completed with 7203 local objects.
From https://github.com/Homebrew/homebrew-core
   bac6904fef..144c2c2c64 master     -> origin/master

地味に重たいので、少し時間がかかるかもしれません。上記が終わったら、再度、brew update を実行してみます。

$ brew update
Updated 1 tap (homebrew/core).
==> New Formulae
.................................
.................................
.................................
.................................

無事に、実行できました。