-
Notifications
You must be signed in to change notification settings - Fork 1.7k
dart cli commands should run pub get #50422
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Is there some way we can make Running |
Yes, for
? |
We have an
Running The downside of doing this everywhere is that: using dart for things that don't have a Today, we have reports that What is the semantics if there is no |
We should probably special cases commands where a |
I'd like to tweak that to say that the change in behavior we want is to:
It's that 2nd part that would help with https://github.com/google/file.dart/issues/204 - getting a new version of package:file after an SDK upgrade. Does that sounds right? Here's the list of the current dart commands:
Some other thoughts: When running
|
I was thinking that those are two orthogonal dimensions, but that we'd want the same behavoir in both cases. And it does look like you have the same values in all our rows. |
There is a possible complication around flutter. If you use |
There's
Yes, I've seen issues with this. In VS Code we have to use So in VS Code we currently detect the SDK and disable the functionality of running individual tests (which makes me sad when working on some packages 🙃). While this works, it's not ideal, and if anybody else has projects with a similar setup to the Dart SDK they won't be handled specially and may have issues. It'd be good if there was some more general way this could be detected/handled (by |
Hmm. Maybe the root issue here is having the behavoir depend on whether you run |
The present issue seems even more critical in Dart 3. Consider a pubspec that doesn't support 3, e.g. |
@mit-mit are we still targeting this for Dart 3? It seems like a nice to have. |
We'd like it in 3 as it's a breaking change in tools behavoir |
Is there any way to disable this with maybe some flags? I have some tests which try to use It also makes my test perform network requests when it could work fully offline. |
|
Yes, we will have a flag
You probably want to do |
If this will be merged for Dart 3, are commands like |
Yes, see: https://dart-review.googlesource.com/c/sdk/+/291500 |
@sigurdm ah, I see it's opt-in per-command and not run for everything. Thanks! :-) |
That sounds like a bug. Can you reproduce this? |
I switched back to stable in the meantime. What triggered it is, I followed your suggestion of using I switched back to the stable channel, and my tests are now passing. Since this was reverted, I'll check if things work again on master. |
Did you run with any other flags? Otherwise dartdev should be skipped, and |
No other flag, no. In any case with the current state of |
If that would be helpful, I also don't mind trying my test suite on a specific commit ID for the Dart SDK to try and investigate. Not sure which Flutter commit exactly had this enabled. If you know, I can easily check again |
The change landed in dart sdk commit: 645511d |
I'm running it through Flutter – my test suite involves Flutter too. |
Ah - sorry. You said the flutter revision. I believe flutter/flutter@7725f59 should have the change. |
I can't seem to reproduce the issue with Are you sure that this is the right revision? The command doesn't complain about an unrecognized flag. But the command still seems to perform a pub check. I tried running
The command then fails with:
Since
What's unexpected is, the package_config.json was overwritten as if dependencies were resolved again. But somehow the command fails anyway:
Maybe the Because if I run the command twice, the second attempt works fine (since the first run restores the |
If the command recognizes But what you are pointing out is indeed a bug. The resolution logic for |
@sigurdm what was the reason for reverting this, and how likely is it to re-land? I'm wondering whether it may be related to discussions at #52067 ( |
I think the chances for relanding this for dart 3.0 are pretty slim. In my understanding it was reverted mainly because how it affected the sdk workflow, but also because there was some doubts about failure modes - what happens eg. in case of no network. (and also some discussions if it would be a ui improvement at all). |
If we're talking about UX, I personally dislike Flutter doing this. Most IDEs already offer running |
From asking around I've heard these arguments against:
|
@rrousselGit can you elaborate on this? -- if you have an up-to-date resolve, the implicit |
Do you know how this was/will be resolved? Dart-Code has some detection of the SDK try and avoid running |
Here's a video of me running Screen.Recording.2023-04-18.at.12.25.19.movNote that I'm also using analyer plugins in this workspace. That could be the cause (maybe the analyzer restarts to restart plugins. Wild guess). Also the project where I'm running |
I can reproduce what @rrousselGit sees. In the analyzer log I can see that both
I can't see any obvious changes in
|
Also we'd had issues with this in the past with Melos. It's a custom command line that used to edit the package_config.json for the sake of bootstrapping mono-repositories with the local code of packages instead of the remote pub.dev implementation – without having to edit the pubspec.yaml (since having to do a back-and-forth between path dependencies and version dependencies is a pain). Commands running pub get automatically meant that they would override the package_config, reverting any change made by melos. Melos later switched to a newer pub feature (pubspec_overrides.yaml files), so this is no longer an issue for that package. But the problem is worth mentioning. |
Running It would be neat if Automatically running of If your IDE has already run I'm not sure which criteria would be used to see if the |
We have decent logic for detecting if we need to run a full resolution.
|
Implemented here: https://github.com/dart-lang/pub/blob/master/lib/src/entrypoint.dart#L624 |
The implicit build_runner stops if a |
So, if the resolution is up-to-date (and the time-stamps are in the right order) that should not happen. But it is a good point, that might be an undesirable side-effect. |
Would it maybe make sense to offer a way to globally disable the Like maybe:
which sets the default for |
I don't think this is the level of configuration we want. That would create a cognitive overhead, and you could not look at a command and know what it is doing out of context. Also this would most likely be something that you want on a project basis (eg. you might not want it in the sdk, but always for a pub project). |
The
flutter
command always runs apub get
when a sub-command that needs a resolution is executed. Thedart
command doesn't. I think the Flutter behavoir is most user friendly, so suggest we align with that.Flutter
Analyze:
Build:
Run:
Dart
The
dart
command does this for test:But not for
analyze
:Or for
compile
:Or for migrate:
Or for run:
The text was updated successfully, but these errors were encountered: