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
{{ message }}
Repository navigation
'pub run' with flutter tool requires redundant 'pub' on the command line #13360
@franzsilva wrote a cool tool for managing launcher icons, and packaged it as a pub package. Apparently, using the flutter tool, a user can't run the script without typing "pub" twice.
For example: flutter pub pub run flutter_launcher_icons:main
We're wondering if the following could work instead: flutter pub run flutter_launcher_icons:main
It's actually flutter packages pub run flutter_launcher_icons:main.
What's going on is that flutter packages sets the environment for pub, then there's a bunch of commands that flutter packages supports (see flutter packages --help). One of those is pub; what that does is call through to pub and hand it the rest of the command line. The other commands are shortcuts to common things you do with pub, though they don't support all the features of pub. Namely, get and upgrade run pub get and pub upgrade, and test runs pub run test.
We want to give our developers a way to extend their workflow with scripts distributed as pub packages. Then, we want to give them a clear way to run those scripts. So, +1 to making it a bit more discoverable and terse to run a workflow script :)
@matanlurey how would we determine if we should run the argument with the dart vm or through pub run? If there is a pubspec.yaml in the same dir or in the parent dir, then use pub run otherwise use the vm?
How would we determine if we should run the argument with the dart vm or through pub run?
One option would be, if the argument represents a path on disk (i.e. tool/file.dart), or you could even say, ends in the string '.dart', use the Dart VM, otherwise use pub run. It's probably safe to always use pub run, though, because I think it works anyway.
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.
Activity
sethladd commentedon Dec 5, 2017
cc @mit-mit @devoncarew
Hixie commentedon Dec 5, 2017
It's actually
flutter packages pub run flutter_launcher_icons:main.What's going on is that
flutter packagessets the environment for pub, then there's a bunch of commands thatflutter packagessupports (seeflutter packages --help). One of those ispub; what that does is call through to pub and hand it the rest of the command line. The other commands are shortcuts to common things you do withpub, though they don't support all the features ofpub. Namely,getandupgraderunpub getandpub upgrade, andtestrunspub run test.mit-mit commentedon Dec 5, 2017
We are starting to see a few of these. I think we should reconsider this more globally as originally suggested in #9799
sethladd commentedon Dec 5, 2017
We want to give our developers a way to extend their workflow with scripts distributed as pub packages. Then, we want to give them a clear way to run those scripts. So, +1 to making it a bit more discoverable and terse to run a workflow script :)
Thanks!
MarkOSullivan94 commentedon Jan 2, 2018
@sethladd any update on this?
mit-mit commentedon Jan 9, 2018
No updates, sorry. For now, please use
flutter packages pub run <dart file>matanlurey commentedon Jan 13, 2018
On the mailing list I suggested
flutter scriptas a shorthand:flutter script <pub package or command-line file.dart>We could combine this with
build_runner's support for code generation quite easily:dart-lang/build#733
mit-mit commentedon Jan 15, 2018
@matanlurey how would we determine if we should run the argument with the dart vm or through
pub run? If there is apubspec.yamlin the same dir or in the parent dir, then usepub runotherwise use the vm?matanlurey commentedon Jan 15, 2018
@mit-mit:
One option would be, if the argument represents a path on disk (i.e.
tool/file.dart), or you could even say, ends in the string'.dart', use the Dart VM, otherwise usepub run. It's probably safe to always usepub run, though, because I think it works anyway.sethladd commentedon Jan 15, 2018
Curious, why would we need to use
pub run? What does that buy us, over the CLI engine?matanlurey commentedon Jan 17, 2018
@sethladd: You don't need to, it just allows packages to define shortcuts like
pub run testImagine:
flutter script optimize-pngsversusflutter script flutter_image_optimizer:optimize-pngsversusflutter script /some/cache/dir/packages/flutter_image_optimizer/bin/optimize_pngs.dartMarkOSullivan94 commentedon Apr 26, 2019
@mit-mit just looking at the merged PR does this mean that the following will now work
flutter packages run flutter_launcher_icons:mainmit-mit commentedon Apr 29, 2019
It should; please give it a try, and let us know if not. Generally any
pub xcommand should now be available asflutter pub xe609577 Revert "Turn on RasterCache based on view hierarchy (flutter#…
e609577 Revert "Turn on RasterCache based on view hierarchy (flutter#…
e609577 Revert "Turn on RasterCache based on view hierarchy (flutter#…
Roll engine 5051bef..e609577 (3 commits) (#43854)
Roll engine 5051bef..e609577 (3 commits) (flutter#43854)
github-actions commentedon Aug 16, 2021
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of
flutter doctor -vand a minimal reproduction of the issue.