Skip to content

'pub run' with flutter tool requires redundant 'pub' on the command line #13360

Closed

Description

@sethladd

@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

Comment: fluttercommunity/flutter_launcher_icons#4 (comment)

Activity

  1. added
    toolAffects the "flutter" command-line tool. See also t: labels.
    on Dec 5, 2017
  2. sethladd commented on Dec 5, 2017

    @sethladd
    ContributorAuthor
  3. Hixie commented on Dec 5, 2017

    @Hixie
    Contributor

    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.

  4. added this to the milestone on Dec 5, 2017
  5. mit-mit commented on Dec 5, 2017

    @mit-mit
    Member

    We are starting to see a few of these. I think we should reconsider this more globally as originally suggested in #9799

  6. sethladd commented on Dec 5, 2017

    @sethladd
    ContributorAuthor

    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!

  7. modified the milestones: , on Dec 6, 2017
  8. MarkOSullivan94 commented on Jan 2, 2018

    @MarkOSullivan94
    Contributor

    @sethladd any update on this?

  9. mit-mit commented on Jan 9, 2018

    @mit-mit
    Member

    No updates, sorry. For now, please use flutter packages pub run <dart file>

  10. matanlurey commented on Jan 13, 2018

    @matanlurey
    Contributor

    On the mailing list I suggested flutter script as a shorthand:

    flutter script <pub package or command-line file.dart>

    $ flutter script some_package
    $ flutter script some_package:some_executable
    $ flutter script tool/some_dart_file.dart

    We could combine this with build_runner's support for code generation quite easily:

    dart-lang/build#733

  11. mit-mit commented on Jan 15, 2018

    @mit-mit
    Member

    @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?

  12. matanlurey commented on Jan 15, 2018

    @matanlurey
    Contributor

    @mit-mit:

    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.

  13. sethladd commented on Jan 15, 2018

    @sethladd
    ContributorAuthor

    Curious, why would we need to use pub run ? What does that buy us, over the CLI engine?

  14. matanlurey commented on Jan 17, 2018

    @matanlurey
    Contributor

    @sethladd: You don't need to, it just allows packages to define shortcuts like pub run test

    Imagine:

    flutter script optimize-pngs versus
    flutter script flutter_image_optimizer:optimize-pngs versus
    flutter script /some/cache/dir/packages/flutter_image_optimizer/bin/optimize_pngs.dart

  15. MarkOSullivan94 commented on Apr 26, 2019

    @MarkOSullivan94
    Contributor

    @mit-mit just looking at the merged PR does this mean that the following will now work

    flutter packages run flutter_launcher_icons:main

  16. mit-mit commented on Apr 29, 2019

    @mit-mit
    Member

    It should; please give it a try, and let us know if not. Generally any pub x command should now be available as flutter pub x

  17. added 4 commits that reference this issue on Oct 30, 2019
  18. added a commit that references this issue on Nov 26, 2019
  19. github-actions commented on Aug 16, 2021

    @github-actions

    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.

  20. locked as resolved and limited conversation to collaborators on Aug 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    toolAffects the "flutter" command-line tool. See also t: labels.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions