yamabico-dailylog

SE兼アマチュアピアニストのブログです。

Homebrewで一苦労した話

現在使用しているMac Book Proは数年前に購入した Early 2015だ。
このモデルでは通常のOSアップデート操作で Serriraより上のOSバージョン(catalina,mojave)にアップデートできない状態にあったため、 App Storeより最新OSをダウンロードしアップデートを実施した。

アップデートを決めた要因は、
前述のSerriraより上のバージョンにあげられない問題や、
そもそも古いOSバージョンを使い続けているリスクと、
加えて、brewコマンドでJDK11など、
開発に関わる一部のライブラリのインストールができない問題が発生していたからだ。

brewコマンド実行でエラーが発生

OSのアップデートは無事完了したので、 早速JDK11をダウンロードすべくbrewコマンドを実行したところ、 以下のエラーが発生。

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!

調べたところ同じ問題が発生した方のQiita記事を見つけた。 内容を読むとHomebrewの仕様に変更が入ったからとのこと。 qiita.com

brew caskでエラー発生

今回JDKAmazon correttoを利用することを考えた。 いくつかの記事を参考に以下のコマンドを実行したが、 caskがないとエラーになった。

brew cask install corretto

別の記事で、caskのインストールが必要と書かれていたので、 以下を実行したが、色々インストールされるものの、 肝心のbrew caskコマンドはエラーのまま。

brew install cask

これについて、原因が分からず結構時間を費やしてしまったが、 Homebrewの本家サイトを確認すると、

brew.sh

を確認すると、caskを利用するには以下のようにコマンドを書くよう記載があった。

brew install --cask {インストールしたいライブラリ・アプリケーション}

まさか、と思いつつ実際試してみると、無事成功・・・。 本家サイトみると大事ですね・・。

$ brew install --cask corretto
Updating Homebrew...
==> Auto-updated Homebrew!
Updated 1 tap (homebrew/core).
==> Updated Formulae
Updated 12 formulae.

==> Tapping homebrew/cask
Cloning into '/usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask'...
remote: Enumerating objects: 34, done.
remote: Counting objects: 100% (34/34), done.
remote: Compressing objects: 100% (24/24), done.
remote: Total 549210 (delta 16), reused 14 (delta 10), pack-reused 549176
Receiving objects: 100% (549210/549210), 241.94 MiB | 4.55 MiB/s, done.
Resolving deltas: 100% (387876/387876), done.
Tapped 3814 casks (3,933 files, 259.6MB).
==> Downloading https://corretto.aws/downloads/resources/15.0.2.7.1/amazon-corre
######################################################################## 100.0%
==> Installing Cask corretto
==> Running installer for corretto; your password may be necessary.
Package installers may write to any location; options such as `--appdir` are ignored.
Password:
installer: Package name is Amazon Corretto 15
installer: Installing at base path /
installer: The install was successful.
🍺  corretto was successfully installed!

とはいえ、上記の通り、JDK15がインストールされてしまったので、 以下で過去バージョンのライブラリ・アプリケーションを取得できるようにし、

brew tap homebrew/cask-versions

correttoのJDK11を取得を実行し、無事完了することができた。

brew install --cask corretto11

これだけで無駄に時間を使ってしまったのが、悔やまれる・・

今夜は以上で。おやすみなさい。