Skip to content

auto-detect when to not prompt for running 'pub get' #2476

Closed

Description

@devoncarew

In some circumstances - in some types of repos - the user should not run pub get. These repos manage their dependencies in other ways (the dart-lang/sdk repo, ...).

For this specific case, we shouldn't prompt if the repo is contained in a bazel workspace. There are a few ways to detect this, generally involving BUILD and / or WORKSPACE files.

Can we auto-detect these situations, and not auto-prompt to run pub get? Thanks!

cc @matanlurey

Activity

  1. DanTup commented on May 19, 2020

    @DanTup
    Member

    We already have code detecting a WORKSPACE file that loads flutter.json:

    const resolvedConfig: WorkspaceConfig = {

    We could add a flag onto the WorkspaceConfig for whether to allow running pub get.

    Should this happen always if there's a WORKSPACE file, or only if there's also a flutter.json file?

    Are there any situations where a user with a Bazel workspace might want to have pub get run automatically? Would it be better stored as an option somewhere in the workspace?

    (note: you can already disable this per-workspace with a VS Code workspace setting, though it would mean committing a .vscode/settings.json file into your workspace).

    We do also have some code to disable running this in the fuchsia tree and for the Dart SDK, which we can probably merge into a single flag for all of these.

  2. added this to the v3.11.0 milestone on May 19, 2020
  3. added
    in commandsRelates to commands (usually invoked from the command Palette)
    is enhancementAn enhancement or improvement that should be listed in release notes but is not a bug fix.
    on May 19, 2020
  4. devoncarew commented on May 19, 2020

    @devoncarew
    ContributorAuthor

    Should this happen always if there's a WORKSPACE file

    I think we can have this always happen if we're within a directory tree with a WORKSPACE file.

    Are there any situations where a user with a Bazel workspace might want to have pub get run automatically?

    I don't think so (and, they'll always have the ability to run it manually).

    We do also have some code to disable running this in the fuchsia tree and for the Dart SDK, which we can probably merge into a single flag for all of these.

    Sounds reasonable -

  5. added a commit that references this issue on May 20, 2020
    ba28e7f
  6. DanTup commented on May 20, 2020

    @DanTup
    Member

    generally involving BUILD and / or WORKSPACE files.

    Is there something I need to handle with a BUILD file that does not have a WORKSPACE file?

    Right now I'm disabling automatic fetching for:

    • Anything with a WORKSPACE file up the tree
    • Anything in a Git repo with a README.dart-sdk file in its root (this was my detection of the Dart SDK repo - I don't know if there's something better)
    • Anything with a .jiri_root folder up the tree

    Let me know if there's anything missing (or that can be improved).

    Btw, I'm also disabling checking for Dart SDK updates for Fuchsia (.jiri_root) and Bazel workspaces, and disabling using pub run for tests in the Dart SDK repo. I'm unsure if either of those should extend to other workspace types though.

  7. devoncarew commented on May 20, 2020

    @devoncarew
    ContributorAuthor

    I think the same logic that we use to fingerprint looking for the .../flutter.json file should work here (I don't remember it off the top of my head, but something like if both a BUILD and a WORKSPACE file exist in a directory above the project in question).

    Re: the automatic fetching, that sounds good.

    Also for sdk checks.

    Bazel projects also won't use pub run for tests, but determining the right bazel target to run for apps and tests is non-trivial from an IDE, and would require additional CLI tooling support in the target workspace.

  8. DanTup commented on May 20, 2020

    @DanTup
    Member

    I think the same logic that we use to fingerprint looking for the .../flutter.json file should work here (I don't remember it off the top of my head, but something like if both a BUILD and a WORKSPACE file exist in a directory above the project in question).

    Sorry, I wasn't very clear. This new change (to stop running pub get automatically) does use the same code for detecting a Bazel workspace as reading flutter.json, but that is only that there is a WORKSPACE file up the tree. There's no check for a BUILD file. I'm not very familiar with Bazel workspace so if there should be something based on a BUILD file too, please let me know how it should work (or if there's somewhere I can read/copy from).

    Bazel projects also won't use pub run for tests, but determining the right bazel target to run for apps and tests is non-trivial from an IDE, and would require additional CLI tooling support in the target workspace.

    The main reason I disable this for the SDK is that pub just fails to run the tests with the editor. So instead we run them through the VM directly (which means they don't appear in the test tree because of no JSON runner, but they do at least run and are debuggable). Would this make sense for Bazel workspaces too? Will _test.dart scripts execute better through dart than pub test?

    Thanks!

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

    in commandsRelates to commands (usually invoked from the command Palette)is enhancementAn enhancement or improvement that should be listed in release notes but is not a bug fix.

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions