问题
I'm on a Mac and I upgraded to Dart 2.8 from Dart 2.7.1 by running
brew upgrade dart
as it describes in the documentation.
However, version 2.8 contains some breaking changes for the Aqueduct framework, so I want to downgrade to Dart 2.7.2.
I tried
brew install dart@2.7.2
but got
Error: No available formula with the name "dart@2.7.2"
I also tried
brew search dart
but only got
dart-lang/dart/dart ✔
dart-lang/dart/dart-beta
dart-lang/dart/dart@1
dart-lang/dart/dart@2
dartsim
There is no option to select a lower 2.x version.
How do I downgrade?
回答1:
run
brew info dart
and find the formula link, for example
From: https://github.com/dart-lang/homebrew-dart/blob/master/dart.rbopen the formula link in your browser, it will take you to the master branch repo page
- click "Raw" and take the raw url from your browser's address bar, for example
https://raw.githubusercontent.com/dart-lang/homebrew-dart/master/dart.rb
- click "Raw" and take the raw url from your browser's address bar, for example
go back with your browser to the repo page and click "History"
- scroll down until you see the version you're interested in, for example "Updated stable branch to revision 2.7.2"
- click on "Updated stable branch to revision 2.7.2" and from the top of the diffs page take the full commit ID (hash) for example fed6de080aef54c4f1c1df732424df37cd3e5a3e
run
brew uninstall dart
install an older version of Dart with
brew install https://raw.githubusercontent.com/dart-lang/homebrew-dart/fed6de080aef54c4f1c1df732424df37cd3e5a3e/dart.rb
- the brew install url is obtained by replacing
master
in the url from step 2. with the commit ID (hash) obtained in step 3.
- the brew install url is obtained by replacing
Note: you can keep the older Dart version (for
brew upgrade
) if you pin it with brew pin dart
来源:https://stackoverflow.com/questions/61648998/how-to-downgrade-dart-with-homebrew