Homebrewにて「homebrew-core is a shallow clone」が出た時の対処方法

はじめに

Homebrewにて「brew update」を実行したところ、以下のようなエラーが発生しました。

$ brew update
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
These commands may take a few minutes to run due to the large size of the repositories.
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!

このコマンドを実行するとサイズが大きいためアップデートに数分かかってしまうとのこと。

そのため、shallow cloneを利用せず、完全なcloneを利用してくださいということみたいですね。

対処方法

エラー内容に記載されているコマンドを実行します。

$ git -C /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core fetch --unshallow
remote: Enumerating objects: 765580, done.
remote: Counting objects: 100% (765440/765440), done.
remote: Compressing objects: 100% (254265/254265), done.
remote: Total 756780 (delta 511157), reused 745183 (delta 499652), pack-reused 0
Receiving objects: 100% (756780/756780), 277.74 MiB | 24.19 MiB/s, done.
Resolving deltas: 100% (511157/511157), completed with 7492 local objects.
From https://github.com/Homebrew/homebrew-core
   364f34b651..d3742bb5ba  master     -> origin/master

$ git -C /usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask fetch --unshallow
remote: Enumerating objects: 494784, done.
remote: Counting objects: 100% (493612/493612), done.
remote: Compressing objects: 100% (144378/144378), done.
remote: Total 487349 (delta 349662), reused 480064 (delta 342412), pack-reused 0
Receiving objects: 100% (487349/487349), 187.87 MiB | 23.74 MiB/s, done.
Resolving deltas: 100% (349662/349662), completed with 4764 local objects.
From https://github.com/Homebrew/homebrew-cask
   a15f4486d0..6c5257c182  master     -> origin/master

再度「brew update」を実行してみます。

brew update
==> Homebrew has enabled anonymous aggregate formula and cask analytics.
Read the analytics documentation (and how to opt-out) here:
  https://docs.brew.sh/Analytics
No analytics have been recorded yet (nor will be during this `brew` run).

Updated 4 taps (homebrew/cask-versions, homebrew/core, homebrew/cask and homebrew/services).
==> New Formulae
・・・
==> Processing curl-openssl formula rename to curl
==> Unlinking curl-openssl
==> Moving curl-openssl versions to /usr/local/Cellar/curl
==> Relinking curl
Warning: curl is outdated!
To avoid broken installations, as soon as possible please run:
  brew upgrade
Or, if you're OK with a less reliable fix:
  brew upgrade curl

You have 40 outdated formulae installed.
You can upgrade them with brew upgrade
or list them with brew outdated.

「brew upgrade」してくださいといわれたので、実行します

$ brew upgrade
==> Upgrading 40 outdated packages:
pkg-config 0.29.2 -> 0.29.2_3
libtiff 4.0.10_1 -> 4.3.0
libtool 2.4.6_1 -> 2.4.6_3
jansson 2.12 -> 2.13.1
gmp 6.1.2_2 -> 6.2.1
nghttp2 1.39.2 -> 1.43.0
・・・
Emacs Lisp files have been installed to:
  /usr/local/share/emacs/site-lisp/libidn

問題ないかどうか「brew doctor」を実行してみます。

 $ brew doctor
Your system is ready to brew.

問題ありませんでした。

最後に

Homebrewは簡単にパッケージをインストールしたり管理したりできますが、初期でつまずくと結構大変でした。

タイトルとURLをコピーしました