LoginSignup
18
4

More than 1 year has passed since last update.

Homebrewは定期的にupdateしないとupdateできなくなるんじゃないか説

Posted at

久しぶりにupdateしようとすると、リポジトリの差分がデカすぎて処理が走らなくなるんじゃないかという話です。
最近あまり記事を書けていなかったので筆慣らしに。

ことの始まり

所用で手持ちのMacBookにJavaを入れたいなーと思い、Homebrewでインストールしようと思いました。
そうと決まればまずはupdateが必要でしょう。

$ brew update
Error: Fetching /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core failed!

うん? なんか怒られてしまいました。

試したこと

困ったときはとりあえずbrew doctorしてみるとよさそうです。

$ brew doctor
Your system is ready to brew.

問題なさそう。あれー?
今度はこっちの記事を見てbrew update-resetを試してみます。

$ brew update-reset
==> Fetching /usr/local/Homebrew...

==> Resetting /usr/local/Homebrew...
Branch 'master' set up to track remote branch 'master' from 'origin'.
Switched to and reset branch 'master'
Your branch is up to date with 'origin/master'.

==> Fetching /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core...
error: RPC failed; curl 92 HTTP/2 stream 5 was not closed cleanly before end of the underlying stream
fatal: protocol error: bad pack header

==> Resetting /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core...
Branch 'master' set up to track remote branch 'master' from 'origin'.
Reset branch 'master'

なんかコケてるじゃないですか。
発端のエラーログといい、問題はhomebrew-coreにありそうです。
Fetchingでコケてるので、今度は直接git fetchしてみましょう。

$ cd /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core
$ git fetch
error: RPC failed; curl 92 HTTP/2 stream 5 was not closed cleanly before end of the underlying stream
fatal: protocol error: bad pack header

やっぱりここが原因っぽいですね。
とはいえ、普通にgit fetchするのではうまく動かないようです。

解決策

重いリポジトリだと落とすのに失敗してしまうことがあるようです。
エラーログこそ違いますが、同じ原因だと推測してこちらの記事の解決策を試してみます。

$ git fetch --depth 1
remote: Enumerating objects: 11060, done.
remote: Counting objects: 100% (11060/11060), done.
remote: Compressing objects: 100% (5172/5172), done.
remote: Total 6140 (delta 5492), reused 1108 (delta 964), pack-reused 0
Receiving objects: 100% (6140/6140), 2.68 MiB | 5.42 MiB/s, done.
Resolving deltas: 100% (5492/5492), completed with 4706 local objects.
From https://github.com/Homebrew/homebrew-core
 + c42e479e59a...d51b09d7f45 master                 -> origin/master  (forced update)
 * [new branch]              recreate-macos-runners -> origin/recreate-macos-runners
$ git fetch --depth 10
remote: Enumerating objects: 102, done.
remote: Counting objects: 100% (100/100), done.
remote: Compressing objects: 100% (43/43), done.
remote: Total 68 (delta 50), reused 43 (delta 25), pack-reused 0
Unpacking objects: 100% (68/68), 19.97 KiB | 104.00 KiB/s, done.
$ git fetch --depth 100
remote: Enumerating objects: 1049, done.
remote: Counting objects: 100% (857/857), done.
remote: Compressing objects: 100% (340/340), done.
remote: Total 693 (delta 513), reused 533 (delta 353), pack-reused 0
Receiving objects: 100% (693/693), 232.82 KiB | 2.84 MiB/s, done.
Resolving deltas: 100% (513/513), completed with 93 local objects.
$ git fetch --depth 10000
remote: Enumerating objects: 73192, done.
remote: Counting objects: 100% (50310/50310), done.
remote: Compressing objects: 100% (20419/20419), done.
remote: Total 46881 (delta 34711), reused 38457 (delta 26461), pack-reused 0
Receiving objects: 100% (46881/46881), 25.98 MiB | 3.66 MiB/s, done.
Resolving deltas: 100% (34711/34711), completed with 2886 local objects.
$ git fetch --depth 1000000
remote: Enumerating objects: 64878, done.
remote: Counting objects: 100% (48076/48076), done.
remote: Compressing objects: 100% (15378/15378), done.
remote: Total 41701 (delta 30015), reused 37965 (delta 26320), pack-reused 0
Receiving objects: 100% (41701/41701), 17.27 MiB | 5.78 MiB/s, done.
Resolving deltas: 100% (30015/30015), completed with 2897 local objects.
$ git fetch --unshallow
fatal: --unshallow on a complete repository does not make sense

最後にエラーが出ていますが、こちらはunshallowの必要がないよというものですね。
これでOKでしょう。再度brew updateを試してみます。

❯ brew update
Updated 1 tap (homebrew/core).

OK!

終わりに

Homebrewは活発に更新されているようなので、しばらく放置すると差分がかなり大きくなってしまうようですね。
しっかり原因究明したわけではないですが、定期的にupdateしてあげた方がよさそうです。

18
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
18
4