问题
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
...
回答1:
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
回答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
回答3:
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.
来源:https://stackoverflow.com/questions/50928834/how-to-upgrade-to-dart-2