How to downgrade Dart with Homebrew

允我心安 提交于 2020-06-12 09:13:20

问题


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:


  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

    • 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
  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
  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

    • the brew install url is obtained by replacing master in the url from step 2. with the commit ID (hash) obtained in step 3.


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!