猫でもわかるWebプログラミングと副業

本業エンジニアリングマネージャー。副業Webエンジニア。Web開発のヒントや、副業、日常生活のことを書きます。

【Homebrew】homebrew-core is a shallow clone. To `brew update` first run:

f:id:yoshiki_utakata:20201215092645p:plain

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 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. 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!

homebrew-core が shallow clone になっているので、 --unshallow で clone しろよと。

言われるがまま、このコマンドを実行する。

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

すると別のエラーが出る。

Error: homebrew-cask is a shallow clone. To `brew update` first run:
  git -C "/usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask" 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-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!

さっきと同じように見えるが微妙に違う。

さっきのは homebrew-core 、今回のは homebrew-cask

ということで、また言われるがままコマンドを叩く。

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

1つ目のエラーと2つめのエラーが違うことは、この issue を読んで気づいた。

github.com

このエラー文言は限りなく親切なエラー文言であるが、2つのエラー文言が重なることで、限りなく分かりづらいエラー(エラーが解消されていないように見える)になる。

core と cask が両方インストールされていない場合は、両方のエラーをまとめて出す、とかが良さそうだ。