-
Notifications
You must be signed in to change notification settings - Fork 229
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
Ensure Dart version is at least as high as dependencies #4488
Comments
The sdk constraint is for the package itself, and doesn't cover the dependencies. It is a bit confusing, but I think it makes the most sense Consider the case where a new version 1.5.1 of pubspec_parse was published with a lower sdk constraint. Now the project actually would work with the older sdk. The sdk constraint is also used for specifying the language version, so that might be one reason to leave it lower than the dependencies. If you look at the pubspec.lock, it has a section at the bottom like:
It specifies the intersection of all sdk constraints of all packages in the resolution. I remember discussing this before, but cannot find the exact issue to link. Closest I could find was this: #2007 |
In other words,
having the pubspec declare an SDK version lower than the dependencies is misleading because you can't actually run the project with the version you see in front of you, and instead have to "just try it" and see what you need. The bigger problem is that if the developer happens to have a recent version of Dart/Flutter, they won't even notice that running Having an error/warning when the pubspec SDK version isn't high enough should fix those issues. But it would also be helpful if |
Here is another, related error message, caused by having Resolving dependencies...
Note: meta is pinned to version 1.12.0 by flutter from the flutter SDK.
See https://dart.dev/go/sdk-version-pinning for details.
Because analyzer >=6.5.1 depends on meta ^1.15.0 and analyzer >=6.5.0 <6.5.1 depends on meta ^1.14.0, analyzer >=6.5.0 requires meta ^1.14.0.
And because every version of flutter from sdk depends on meta 1.12.0, flutter from sdk is incompatible with analyzer >=6.5.0.
And because ffigen >=16.0.0 depends on dart_style ^2.3.7 which depends on analyzer ^6.5.0, flutter from sdk is incompatible with ffigen >=16.0.0.
So, because flutter_local_notifications_windows depends on both flutter from sdk and ffigen ^16.0.0, version solving failed. The error makes sense:
Of course, on my system I have the latest Flutter, which doesn't bring up these issues. The problem comes up because I've asked that my project be compatible with Flutter 3.22, which means only my CI (or worse, a user) will encounter this issue, and not me. Again, the errors make sense, but what's very confusing here is having a pubspec that says "my project should be compatible with Dart XXX and Flutter YYY", and Pub lets you do that, even though that's not the case, and you have to figure that out the hard way. And as I mentioned, running Now, the Flutter case is different, since I'm not sure how Pub should just "know" that Flutter used to pin to a different version of meta. I'm not sure if Flutter has the equivalent of a pubspec who's older versions can be easily queried like packages on Pub can. I can open a new issue at flutter/flutter if needed, but I think the root cause is going to be the same for Dart as well. |
(Duplicating this from Workiva/dependency_validator#141, since I think this has value being integrated into Pub directly).
Say I have the following project:
This compiles, and Pub doesn't complain. However,
pubspec_parse
version 1.5 requires Dart 3.6! Everything works because, coincidentally, I happen to have Dart 3.6 on my PC. But someone else might not, especially a CI workflow (this happens to me all the time). I have a use case where I need to be entirely offline, so I'd like to know if I need to upgrade my Dart SDK as far in advance as possible. In general, I want to know when updating a dependency will cause my project's minimum Dart version to increaseAs for transitive dependencies, it's probably safer to check each package in
.dart_config/package_config.json
and flag the highest Dart version required by any dependency, preferring to show direct dependencies when possible.The text was updated successfully, but these errors were encountered: