Skip to content
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

Open
Levi-Lesches opened this issue Jan 11, 2025 · 1 comment
Open

Ensure Dart version is at least as high as dependencies #4488

Levi-Lesches opened this issue Jan 11, 2025 · 1 comment

Comments

@Levi-Lesches
Copy link
Contributor

(Duplicating this from Workiva/dependency_validator#141, since I think this has value being integrated into Pub directly).


Say I have the following project:

environment:
  sdk: ^3.0.0

dependencies:
  pubspec_parse: ^1.5.0

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 increase

As 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.

@sigurdm
Copy link
Contributor

sigurdm commented Jan 13, 2025

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:

sdks:
  dart: ">=3.5.0 <4.0.0"

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants