RPC failed; curl 56 LibreSSL SSL_read: SSL_ERROR_SYSCALL, errno 60を解決する

やったこと

rbenvでrubyのバージョンを変更したかった

 変更しようとしたら以下のエラーが出た。

$ rbenv install 2.5.9                                                                                                                                                                                     
ruby-build: definition not found: 2.5.9

See all available versions with `rbenv install --list'.

If the version you need is missing, try upgrading ruby-build:

  brew update && brew upgrade ruby-build

brew update && brew upgrade ruby-buildを実行するとhomebrewをフルでcloneしろと言われる

 サイズは大きいらしい。。

$ brew update && brew upgrade ruby-build                                                                                                                                                                  ✘ 2 
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 command may take a few minutes to run due to the large size of the repository.
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!

git -C /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core fetch --unshallowを実行するとエラー

$ git -C /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core fetch --unshallow                                                                                                                        ✘ 1 
error: RPC failed; curl 56 LibreSSL SSL_read: SSL_ERROR_SYSCALL, errno 60
fatal: the remote end hung up unexpectedly
fatal: protocol error: bad pack header

 このエラーの原因は、どうやらgitのバッファが少ないことらしい。大きいサイズをcloneするので拡張する必要があるのか?

バッファのサイズを拡張してみた

 コマンド実行前はバッファについての設定は一切していなかった。

$ git config --global http.postBuffer 16M

参考:
tree-tree-diary.hatenablog.com

拡張後再度cloneを実行

 ちゃんと通った。

git -C /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core fetch --unshallow
remote: Enumerating objects: 761838, done.
remote: Counting objects: 100% (761791/761791), done.
remote: Compressing objects: 100% (259444/259444), done.
remote: Total 751876 (delta 503444), reused 737807 (delta 489557), pack-reused 0
Receiving objects: 100% (751876/751876), 304.35 MiB | 3.18 MiB/s, done.
Resolving deltas: 100% (503444/503444), completed with 8266 local objects.
From https://github.com/Homebrew/homebrew-core

 解決。