Skip to content

flutter dart foo.dart to run dart foo.dart with FLUTTER_ROOT set #13607

Closed

Description

@kevmoo

Required to run things like source_gen generators.

#13360 deals with pub run. This is just getting access to the dart command to run things not in the bin directory.

Here's the draft text I've included in json_serializable – which is pretty gnarly.


NOTE: If you're using Flutter, running a Dart script is a bit tricky. You can
find the Dart entry point at $FLUTTER_ROOT/bin/cache/dart-sdk/bin/dart.
You can determine FLUTTER_ROOT by looking at the first few lines of
flutter doctor.

> flutter doctor
[✓] Flutter (on Mac OS X 10.12.6 16G1114, locale en-US, channel master)
    • Flutter at YOUR_FLUTTER_ROOT_HERE
    • Framework revision 235b64ed2f (13 hours ago), 2017-12-14 20:38:39 -0800
...

Activity

  1. kevmoo commented on Dec 15, 2017

    @kevmoo
    ContributorAuthor
  2. sethladd commented on Dec 15, 2017

    @sethladd
    Contributor

    Strawman: flutter cmd <path_to_cli_script> which simply runs the script via the same Dart version that is used in the engine (so the API in docs.flutter.io applies to scripts run via the Flutter cmd line. I don't want "two darts" for Flutter developers, there is one Dart for Flutter developers: the Dart that is documented on docs.flutter.io)

    In the meantime, could source_gen ship a generic runner accessible from pub run ?

  3. kevmoo commented on Dec 15, 2017

    @kevmoo
    ContributorAuthor

    Strawman: flutter cmd <path_to_cli_script>

    SGTM...

    In the meantime, could source_gen ship a generic runner accessible from pub run ?

    Sadly, no. We're working on a solution w/ pkg/build where there will be a common entry point. Hoping to have that nailed down in Q1.

  4. added
    toolAffects the "flutter" command-line tool. See also t: labels.
    on Dec 18, 2017
  5. mit-mit commented on Dec 18, 2017

    @mit-mit
    Member

    Would a more idea solution be some way to register (maybe in pubspec.yaml, that flutter should execute some dart "script" during build? Then you wouldn't need to remember to manually run the generators?

  6. kevmoo commented on Dec 18, 2017

    @kevmoo
    ContributorAuthor
  7. changed the title [-]Make it easier to run the `dart` executable[/-] [+]`flutter dart foo.dart` to run `dart foo.dart` with FLUTTER_ROOT set[/+] on Jun 12, 2018
  8. added this to the milestone on Jun 12, 2018
  9. zoechi commented on Jan 22, 2019

    @zoechi
    Contributor

    flutter packages pub run tool/build.dart does this currently.

  10. jonahwilliams commented on Apr 22, 2019

    @jonahwilliams
    Contributor

    Closing as pub can run dart scripts, and because we'll likely use a different solution for build_runner integration.

  11. mit-mit commented on Apr 22, 2019

    @mit-mit
    Member

    Also, note that I recently added passthrough for all pub commands, so the current shortest way of doing this is:

    flutter pub run tool/build.dart
    
  12. github-actions commented on Aug 15, 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.

  13. locked as resolved and limited conversation to collaborators on Aug 15, 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

    c: new featureNothing broken; request for a new capabilitytoolAffects 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