darthomebrewaqueduct

How to downgrade Dart with Homebrew


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?


Solution

    1. run brew info dart and find the formula link, for example
      From: https://github.com/dart-lang/homebrew-dart/blob/master/dart.rb

    2. open the formula link in your browser, it will take you to the master branch repo page

    3. 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
        (save the full commit ID (hash), you will need it in step 5)
    4. run brew uninstall dart

    5. install an older version of Dart with
      brew install https://raw.githubusercontent.com/dart-lang/homebrew-dart/fed6de080aef54c4f1c1df732424df37cd3e5a3e/dart.rb

      • In the command above, the url is obtained by using the url you saved in step 2 and replacing the word master with the commit ID (hash) fed6de080aef54c4f1c1df732424df37cd3e5a3e obtained in step 3.

    ***Note:*** you can keep the older Dart version (for `brew upgrade`) if you pin it with `brew pin dart`