Homebrewが使えない!
先日、とあるアプリを入れようとしてHomebrewCaskのコマンドを打った際に以下のようなエラーが出てインストールが出来ませんでした。
Error:
homebrew-core is a shallow clone.
homebrew-cask is a shallow clone.
To `brew update`, first run:
git -C /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core fetch --unshallow
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-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!
なんぞこれ!!
原因
シャロークローンが原因
これはHomebrewが以前はシャロークローンと呼ばれる作業コストが高い手法を採用していたのですが、Github様から直々に止めてくれ!!と言われたらしく、そちらを廃止して通常のクローンを採用したため、Homebrewの設定を変えてください、というエラーになります。
なるほど!Githubからのお願いとあれば従う以外に選択肢はありませんな。。。。
では、原因がわかったところで解決をしていきましょう♪
解決方法
エラー出力にあるコマンドを実行する
解決方法はとても簡単です。
エラーメッセージが表示された際にご親切に解決するためのコマンドを添えてくれています。
そちらも実行すれば万事解決でござる。
今回はHomebrewCaskも使っているので以下の二つのコマンドを実行すればおk。
remote: Enumerating objects: 861589, done.
remote: Counting objects: 100% (861541/861541), done.
remote: Compressing objects: 100% (281303/281303), done.
remote: Total 851905 (delta 580344), reused 839151 (delta 567711), pack-reused 0
Receiving objects: 100% (851905/851905), 330.51 MiB | 533.00 KiB/s, done.
Resolving deltas: 100% (580344/580344), completed with 8025 local objects.
From https://github.com/Homebrew/homebrew-core
1330abc8a59..a72ca7f033e master -> origin/master
remote: Enumerating objects: 108659, done.
remote: Counting objects: 100% (104775/104775), done.
remote: Compressing objects: 100% (34123/34123), done.
remote: Total 97165 (delta 70739), reused 89300 (delta 63005), pack-reused 0
Receiving objects: 100% (97165/97165), 46.50 MiB | 644.00 KiB/s, done.
Resolving deltas: 100% (70739/70739), completed with 4122 local objects.
From https://github.com/Homebrew/homebrew-cask
caf689f840..0f71945fcd master -> origin/master
これで正常にbrew updateが成功するようになりました♪
Updating Homebrew...
==> Downloading https://ghcr.io/v2/homebrew/portable-ruby/portable-ruby/blobs/sha256:0cb1cc7af109437fe0e020c9f3b7b95c3c709b140bde9f991ad2c1433496dd42
######################################################################## 100.0%
==> Pouring portable-ruby-2.6.8.yosemite.bottle.tar.gz
==> Auto-updated Homebrew!
終わりに
以上のように過去に出来ていた環境でもエラーが出ると思います。
同じ症状でお困りの方は是非試してみてください♪
