はじめに
Carthage 0.38.0 をインストール しようとしたら、
既に0.37.0 が入っているしそれが最新だよと言われました。
$ brew upgrade carthage
Warning: carthage 0.37.0 already installed
Homebrew 自体のアップデートから Carthage をアップデートするまで
諸々対処したのでまとめます。
前提条件
Mac: macOS Catalina 10.15.6
Homebrew をアップデートする
まずは 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!
いきなり怒られました!🤯
brew update を実行するためにはまず以下のコマンドを打て、と言われています。
git -C /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core fetch --unshallow
git -C /usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask fetch --unshallow
その下に書かれているのは、意訳すると以下のような感じです。
GitHub の要請で shallow clone にしていました。 unshallow は時間などのコストがかかるため、CIで毎回自動実行されるとやばいことになるので、 手動で unshallow してもらってる状況です。 (というかそのような場合はshallow clone しないように修正すべきですね)
そもそも shallow clone とは🤔
shallow clone とは
古いコミットを切り捨ててgit clone する機能のようです。
公式ブログに説明がありました。
シャロークローンは、
https://github.blog/jp/2021-01-13-get-up-to-speed-with-partial-clone-and-shallow-clone/git clone
の--depth=<N>
パラメータを使って
コミット履歴を切り捨てます。
clone するのが早くなりそうなので一見良い機能に見えますが、そうでもなさそうです。
非常にピーキーな機能のようなので、日々の業務では積極的に採用しない方がよさそうですね。
これらの理由から、
https://github.blog/jp/2021-01-13-get-up-to-speed-with-partial-clone-and-shallow-clone/
その後すぐにリポジトリを削除するようなビルドのケースを除いて、
シャロークローンはお勧めしません。
シャロークローンからのフェッチは、
メリットよりもデメリットの方が大きくなることがあります。
unshallow コマンドを打つ
Homebrew が指定した2つのコマンドを打ちます。
$ git -C /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core fetch --unshallow
略
From https://github.com/Homebrew/homebrew-core
fe112d0e1b..259931b1d2 master -> origin/master
$ git -C /usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask fetch --unshallow
略
From https://github.com/Homebrew/homebrew-cask
05081b9fd0..2e49b12876 master -> origin/master
数分待てば完了します。
改めて brew update を打つ
$ brew update
略
You have 12 outdated formulae and 2 outdated casks installed.
You can upgrade them with brew upgrade
or list them with brew outdated.
正常に完了したようです。
続いて Carthage をアップデートします!
パッケージをアップデートする
brew upgrade
と打ちます。
$ brew upgrade
略
==> Upgrading carthage 0.37.0 -> 0.38.0
略
==> Pouring carthage--0.38.0.catalina.bottle.tar.gz
==> Caveats
Bash completion has been installed to:
/usr/local/etc/bash_completion.d
==> Summary
🍺 /usr/local/Cellar/carthage/0.38.0: 8 files, 7.7MB
略
0.37.0 しか入れられなかったのが、0.38.0 を入れることに成功しました!
$ carthage version
0.38.0
最後に
以上です。
Carthage を 0.36.0 から 0.38.0 に上げるのにそこそこ苦労しました。
- [Mac][Homebrew] brew reinstall XXX で /usr/local/lib/node_modules/npm/node_modules/.bin/ のパーミッションエラーが出る場合の対処法
- [Mac] UNIX のユーザとグループの世界観
本ポストも本当の目的の途中経過です。
環境構築は難しいですね 😇
お疲れ様でした!