-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Description
This is especially annoying with workspaces, but also valid for regular projects.
Attempting to run dart run <some-script> will result in an error like the following:
dart run melos
Resolving dependencies in `<path>`...
Because <some-package> requires the Flutter SDK, version solving failed.
Flutter users should use `flutter pub` instead of `dart pub`.
Note the error message also mentions flutter pub - but I never ran dart pub.
Underlying issue
The underlying issue is that dart run attempts to do a dart pub get, and this fails because of the flutter dependency, when using dart which resolves to a normal Dart SDK.
Workarounds
Use dart from the flutter SDK
This does work if you use dart from the flutter SDK.
This is hard to discover though, the error message should ideally tell you this.
We should also maybe consider a flutter dart command? Seems dumb, but would be an easy way to delegate to the dart SDK that is shipped with your flutter SDK.
Use flutter pub run
This also works, but will complain it is deprecated.
Alternate solutions
Could we get an easy way to not run pub get with dart run? The message could then suggest running that way. I thought such an option existed but could not find it via --help.