【Dart】Dartをアップデートしようとした際につまづいた点

Flutter/Dart

パッケージを導入する際に以下のエラーに遭遇

pub get failed (1; Because flame_realtime_shooting requires SDK version >=2.16.0 <3.0.0, version solving failed.)
exit code 1

ターミナルで “dart –version”を叩いて現在導入されているバージョンを確認すると2.14.4とのことなので、バージョンアップが必要そうです。

Dart SDK version: 2.14.4 (stable) (Wed Oct 13 11:11:32 2021 +0200) on "macos_x64"

dartのバージョンアップを実施したので備忘録としてまとめておこうと思います。

【環境】

・MacBookPro2019 16インチ

・OS : Monterey v12.2.1

【Dartのバージョンアップ方法】

参考 : https://dart.dev/get-dar

以下を順に実施

brew tap dart-lang/dart
brew install dart

以下のエラーが出力されました。

※一部省略
############ 100.0%
dart 2.14.4 is already installed but outdated (so it will be upgraded).
==> Fetching dart-lang/dart/dart
==> Downloading https://storage.googleapis.com/dart-archive/
Already downloaded: /Users/hoge/Library/Caches/Homebrew/downloads/303eac19f17c974d44fa10207d676805e512d2a69bf34df364917eb25f97a56a--dartsdk-macos-x64-release.zip
==> Upgrading dart-lang/dart/dart
  2.14.4 -> 2.18
Error: Your Command Line Tools are too outdated.
Update them from Software Update in System Preferences.

If that doesn't show you any updates, run:
  sudo rm -rf /Library/Developer/CommandLineTools
  sudo xcode-select --install

Alternatively, manually download them from:
  https://developer.apple.com/download/all/.
You should download the Command Line Tools for Xcode 13.4.

「コマンドラインツールが古い」みたいなことが言われているみたいです。そのため、一度削除をして再度インストールします。

sudo rm -rf /Library/Developer/CommandLineTools
sudo xcode-select --install

インストール後、再度 “brew install dart” を実行

Dart SDK version: 2.18.5 (stable) (Tue Nov 22 15:47:29 2022 +0000) on "macos_x64"

無事にバージョンアップできたようです。

アップデート類は一つアップデートするのにいくつも更新しなければいけなかったり大変ですね。

コメント

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