Homebrew「homebrew-cask is a shallow clone」の原因と解決方法
Macでbrew update実行時に「Error: homebrew-cask is a shallow clone. To brew update first run:」が発生した場合の対処法を解説します。fetch –unshallowの実行方法や原因、Apple Silicon・Intel Macそれぞれの確認方法まで紹介します。
目次
環境
- OS mac 10.15.5
エラー全文
brew update時に発生。
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!対処法
自分の場合は、記述されている通り以下を実行すると解決しました。
git -C "/usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask" fetch --unshallow
エラーの原因
このエラーは、HomebrewのTapリポジトリが「shallow clone(浅いクローン)」になっている場合に発生します。
Error: homebrew-cask is a shallow clone.
To `brew update` first run:2020年12月頃のHomebrewの仕様変更により、GitHubからの要請を受けてshallow cloneのまま更新することができなくなりました。
エラーメッセージに表示されたコマンドを実行する
まずは、表示されたコマンドをそのまま実行します。
git -C "$(brew --repo homebrew/cask)" fetch --unshallow処理には数分かかる場合があります。
homebrew-coreでも同様のエラーが発生する場合
homebrew-coreでも同様のエラーが表示される場合は、以下を実行します。
git -C "$(brew --repo homebrew/core)" fetch --unshallowbrew updateを再実行する
unshallow処理が完了したら、再度アップデートを実行します。
brew updateApple SiliconとIntel Macの違い
Homebrewのインストール先はMacのCPUによって異なります。
- Intel Mac:
/usr/local - Apple Silicon(M1/M2/M3):
/opt/homebrew
$(brew --repo)を利用することで、環境を意識せず実行できます。
それでも解決しない場合
Tapの状態が壊れている場合は、一度Tapを削除して再追加することで解決することがあります。
brew untap homebrew/cask
brew tap homebrew/cask参考リンク
- Homebrew公式Discussion(Why is a full clone required?)
shallow cloneが廃止された背景について説明されています。 - Homebrew公式ドキュメント
Homebrewの基本的な使い方やトラブルシューティングを確認できます。 - Git公式ドキュメント(git fetch)
fetchや–unshallowオプションの詳細を確認できます。
-
前の記事
javascript localStorageが利用できるかを確認する 2021.02.12
-
次の記事
python 圧縮化されたファイルを解凍する 2021.02.12
コメントを書く