You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
dart pub run has been deprecated for years in favor of dart run.
The two commands have subtle differences in their command resolution and how they chose whether to recompile or not.
So we could choose to either
remove pub run
strictly align the two
Both might have a migration cost so I think the best choice might be to just rip off the bandage and remove it. I think an actual alignment would be very hard, because dart run can do a lot more than pub run.
We would now no longer have a way of running from a flutter invocation. Not sure if that is a problem. But in that case we could consider introducing a flutter dart or something.
cc @mit-mit are there anyone we should ask or warn?
I don't believe dart run works in a Flutter project with Flutter dependencies. IIRC the reason we have to do flutter pub run in some of these cases is because dart run will complain about there being flutter dependencies. This applies specifically for when you try to run one of your dev dependencies that in the package graph doesn't actually depend on a flutter package, but the way that the package resolution works is for your root package.
Did we change dart run to support running dev deps that don't depend on Flutter while the root project or another dependency depends on the Flutter SDK? If not, I don't think we can remove flutter pub run just yet.
@sigurdm, why is this? Is this hard-coded somewhere that we look up those folders to see if we are inside a Flutter SDK?
I'm asking this because I want to understand how some puro commands are working (they use symlinks to share the same Dart SDK install across different Flutter patches - if they are the same version) and how I could help fix this.
I'm wondering:
Say we have Dart at /foo/other/dart-sdk
And a Flutter SDK at /bar/flutter/
With /bar/flutter/bin/dart pointing to the first folder above
If we ran from inside the Flutter SDK, would it still work? Or would we try to look up two folders from /foo/other/dart-sdk?
I think I've figured it out. Even knowing this wouldn't help. I'm creating a PR to set the env var.
Activity
mit-mit commentedon Jan 15, 2026
Do we have any analytics on how used
dart pub runin our most recent stable?sigurdm commentedon Jan 16, 2026
Numbers from last 30 days:
dart run 13045847
dart pub run 62390
So certainly still being used, but not a lot...
sigurdm commentedon Jan 16, 2026
As a warmup we can go through these searches and migrate where needed
https://github.com/search?q=org%3Adart-lang+%22pub+run%22&type=code
https://github.com/search?q=org%3Aflutter+%22pub+run%22&type=code
https://github.com/search?q=org%3Agoogle%20%22pub%20run%22&type=code
Update test command from 'pub run test' to 'dart test'
Update test command from 'pub run test' to 'dart test' (#498)
Change `pub run` to `dart run` in README.md
Replace `pub run` with `dart run` in build script comment
dcharkes commentedon Jan 22, 2026
I don't believe
dart runworks in a Flutter project with Flutter dependencies. IIRC the reason we have to doflutter pub runin some of these cases is becausedart runwill complain about there being flutter dependencies. This applies specifically for when you try to run one of your dev dependencies that in the package graph doesn't actually depend on a flutter package, but the way that the package resolution works is for your root package.Did we change
dart runto support running dev deps that don't depend on Flutter while the root project or another dependency depends on the Flutter SDK? If not, I don't think we can removeflutter pub runjust yet.sigurdm commentedon Jan 22, 2026
As long as you invoke with
FLUTTER_ROOT/bin/dartor otherwise set your$FLUTTER_ROOTvariable it should work.Change `pub run` to `dart run` in README.md (#1044)
Replace `pub run` usages with `dart run` (#2777)
Replace `pub run` mentions with `dart run` (#181317)
Replace pub run with dart run (#10849)
Replace pub run with dart run (#10849)
Replace `pub run` mentions with `dart run` (flutter#181317)
Replace pub run with dart run (#4182)
Replace `pub run` usages with `dart run` (#2777)
FMorschel commentedon Mar 27, 2026
Old comment
@sigurdm, why is this? Is this hard-coded somewhere that we look up those folders to see if we are inside a Flutter SDK?
I'm asking this because I want to understand how some
purocommands are working (they usesymlinks to share the same Dart SDK install across different Flutter patches - if they are the same version) and how I could help fix this.I'm wondering:
/foo/other/dart-sdk/bar/flutter//bar/flutter/bin/dartpointing to the first folder aboveIf we ran from inside the Flutter SDK, would it still work? Or would we try to look up two folders from
/foo/other/dart-sdk?I think I've figured it out. Even knowing this wouldn't help. I'm creating a PR to set the env var.
Replace `pub run` usages with `dart run` (#2777)
Replace `pub run` usages with `dart run` (#2777)
Replace pub run with dart run (flutter#10849)
Replace `pub run` mentions with `dart run` (#181317)