How to upgrade to Dart 2?
Asked Answered
H

5

8

In my macOS I need to install or upgrade to dart 2. But when I try I m getting this error. Any help please?

$ brew install dart
Warning: dart-lang/dart/dart 1.24.3 is already installed and up-to-date
To reinstall 1.24.3, run `brew reinstall dart`
$ brew install dart --devel
==> Installing dart from dart-lang/dart
Error: dart 1.24.3 is already installed
To upgrade to 2.0.0-dev.63.0, run `brew upgrade dart`
$ brew upgrade dart
Error: dart-lang/dart/dart 1.24.3 already installed
...
Homo answered 19/6, 2018 at 12:46 Comment(0)
K
4

Here is an alternative to what Gunter suggested.

Install Dart 2 without uninstalling Dart 1

> brew upgrade dart --devel --force

If you don't have Dart 1 installed, then simply use:

> brew install dart --devel

Switching between Dart 1 and Dart 2

To switch to Dart 1, use the switch command followed by the version of Dart 1 that you have installed. For example:

> brew switch dart 1.24.3

Switching back to Dart 2 is similar, for example:

> brew switch dart 2.0.0-dev.64.1

Listing Dart versions

If you aren't sure which versions of dart you have installed, then run brew info:

> brew info dart
dart-lang/dart/dart: stable 1.24.3, devel 2.0.0-dev.64.1
The Dart SDK
https://www.dartlang.org/
***[Your locally installed versions of dart will be listed here]*** 

Using dart@2 and dart@1 formulas

Until Dart 2 final is released, you can use the brew formulas dart@1 and dart@2 as illustrated below.

WARNING: these formulas are keg-only, which means installed binaries are not symlinked in the usual way. Follow the instructions in the command output to set your PATH appropriately.

> brew install dart@2

==> Installing dart@2 from dart-lang/dart
==> Downloading https://storage.googleapis.com/dart-archive/channels/dev/release/2.0.0-dev.64.1/sdk/dartsdk-macos-x64-release.zip

######################################################################## 100.0%

==> Caveats

Note that this is a prerelease version of Dart.

Please note the path to the Dart SDK:

  /<your-brew-root-path>/opt/dart@2/libexec

This formula is keg-only, which means it was not symlinked into /...,
because this is an alternate version of another formula.

If you need to have this software first in your PATH run:

  echo 'export PATH="/<your-brew-root-path>/opt/dart@2/bin:$PATH"' >> ~/.bash_profile
Krahmer answered 21/6, 2018 at 13:31 Comment(2)
Thanks @Patrice this is what I am looking for.Getter
I follow the instruction and upgrade to Dart 2. :)Homo
E
2

The warning text seems to be a bit unfortunate.

As far as I remember this worked for me

brew uninstall dart
# brew install dart --devel
brew install dart@2 # new
Exquisite answered 19/6, 2018 at 12:54 Comment(0)
M
0
brew uninstall dart
brew tap dart-lang/dart
brew install dart --devel
brew upgrade dart     

you need brew install dart --devel since dart version 2 is still in beta and as such is only available on the developer channel.

Moist answered 19/6, 2018 at 13:54 Comment(0)
L
0

If you got 403 (forbidden) response

curl: (22) The requested URL returned error: 403 

try this

You would have problem with switching on brew 2.6 and above. The brew switch command was removed after the 2.6 release of Homebrew here

  1. download sdk from source as mentioned here

  2. unzip at /usr/local/Cellar/dart and name extracted directory to sdk version: e.g 2.12.4/

  3. change previous version directory name : e.g 2.8.4 -> dart-backup now you should have two directory : 2.12.4/ and dart-backup/

  4. brew unlink dart to remove symlinks

  5. brew info dart and make sure non of versions under Conflicts with are selected. (here you should see both 2.12.4 and dart-backup directories)

  6. brew link dart and it will link to 2.12.4

These steps worked for me

Leninist answered 4/5, 2021 at 12:54 Comment(0)
A
0

In the case, you install dart with flutter. Just need to run this command line: flutter upgrade Then flutter will upgrade the dart sdk too.

Alfrediaalfredo answered 8/3, 2022 at 5:31 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.