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
auto-detect when to not prompt for running 'pub get' #2476
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!
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.
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.
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.
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.
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?
Activity
DanTup commentedon May 19, 2020
We already have code detecting a WORKSPACE file that loads
flutter.json:Dart-Code/src/shared/utils/bazel.ts
Line 27 in 205a45e
We could add a flag onto the
WorkspaceConfigfor whether to allow runningpub get.Should this happen always if there's a
WORKSPACEfile, or only if there's also aflutter.jsonfile?Are there any situations where a user with a Bazel workspace might want to have
pub getrun 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.jsonfile 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.
devoncarew commentedon May 19, 2020
I think we can have this always happen if we're within a directory tree with a WORKSPACE file.
I don't think so (and, they'll always have the ability to run it manually).
Sounds reasonable -
Improve handling of different workspace types
DanTup commentedon May 20, 2020
Is there something I need to handle with a
BUILDfile that does not have aWORKSPACEfile?Right now I'm disabling automatic fetching for:
WORKSPACEfile up the treeREADME.dart-sdkfile in its root (this was my detection of the Dart SDK repo - I don't know if there's something better).jiri_rootfolder up the treeLet 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 usingpub runfor tests in the Dart SDK repo. I'm unsure if either of those should extend to other workspace types though.devoncarew commentedon May 20, 2020
I think the same logic that we use to fingerprint looking for the
.../flutter.json fileshould work here (I don't remember it off the top of my head, but something like if both aBUILDand aWORKSPACEfile 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 runfor 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.DanTup commentedon May 20, 2020
Sorry, I wasn't very clear. This new change (to stop running
pub getautomatically) does use the same code for detecting a Bazel workspace as readingflutter.json, but that is only that there is aWORKSPACEfile up the tree. There's no check for aBUILDfile. I'm not very familiar with Bazel workspace so if there should be something based on aBUILDfile too, please let me know how it should work (or if there's somewhere I can read/copy from).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.dartscripts execute better throughdartthanpub test?Thanks!