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

dart 2.19 beta.4 reports incorrect version range #3738

Closed
bsutton opened this issue Jan 15, 2023 · 12 comments · Fixed by #3739
Closed

dart 2.19 beta.4 reports incorrect version range #3738

bsutton opened this issue Jan 15, 2023 · 12 comments · Fixed by #3739
Labels
type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)

Comments

@bsutton
Copy link
Contributor

bsutton commented Jan 15, 2023

I have the following pubspec.yaml

name: library
version: 0.0.1
description: A simple command-line application created by dcli
environment: 
  sdk: '>=2.19.0-beta.1 <3.0.0'
dependencies: 
  dcli: 1.36.0
dev_dependencies: 
  lint_hard: ^1.0.0

Note the max sdk is < 3.0.0

When I run dart pub get

dart pub get
Resolving dependencies... 
The current Dart SDK version is 2.19.0-444.4.beta.

Because library requires SDK version >=2.19.0-beta.1 <4.0.0, version solving failed.

Note the upper version is displayed as < 4.0.0 rather than the expected < 3.0.0

FYI:

 dart --version
Dart SDK version: 2.19.0-444.4.beta (beta) (Tue Jan 10 10:24:44 2023 +0000) on "linux_x64"
@srawlins
Copy link
Member

@jonasfj @sigurdm does this seem like a pub bug for another repo?

@sigurdm sigurdm transferred this issue from dart-lang/sdk Jan 19, 2023
@sigurdm
Copy link
Contributor

sigurdm commented Jan 19, 2023

Yeah - this is because we decided to extend the compatibility forwards, such that
dart sdk constraints of >=2.12.0 <3.0.0 gets interpreted as >=2.12 <4.0.0.

We only do this for constraints that enable null-safety:
dart sdk constraints of >=2.9.0 <3.0.0 gets interpreted as >=2.9.0 <3.0.0.

The logic was implemented here: #3572

Original issue here: #3554

The intent is that you will not see the rewritten constraint in error messages (after dart 3 such a constraint is always matched with the current sdk) but for dart 2.19 this can happen... I think I did not really consider that case.

I wonder if this is serious enough that we should try to hotfix it for 2.19? The hotfix would probably be to revert #3572 such that it only takes effect in dart 3.

It will never cause a resolution to fail that would otherwise have succeeded, only it will have a confusing error message.

@mit-mit WDYT?

@jonasfj
Copy link
Member

jonasfj commented Jan 20, 2023

@sigurdm, won't this also be a source of confusion in 3.x?

I think at one-point we considered doing:

Because library requires SDK version >=2.19.0-beta.1 <3.0.0 (interpreted as <4.0.0), version solving failed.

I don't recall why we abandoned it, probably it was messy to carry the information around.

Maybe, we could do something like:

The current Dart SDK version is 2.19.0-444.4.beta.
Packages that support null-safety have had SDK constraints <3.0.0 changed to 4.0.0.

Because library requires SDK version >=2.19.0-beta.1 <3.0.0, version solving failed.

Maybe, we can do a better message. But as I recall the "The current Dart SDK version is 2.19.0-444.4.beta." part comes from a "hint" on the incompatibility... Maybe there is a way we can provide another hint.
Something sort with a dart.dev/go/... link that explains all of this might be nice.

@jonasfj jonasfj added the type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) label Jan 20, 2023
@sigurdm
Copy link
Contributor

sigurdm commented Jan 20, 2023

It is much harder to achieve the error message in dart 3 (because dart 3 is part of the extended range)

We are actually carrying the information around.

I implemented this here https://github.com/dart-lang/pub/blob/master/lib/src/pubspec.dart#L659 . But due to the way we calculate a union of sdk constraints here:

var sdkConstraint = await foldAsync<VersionConstraint, PackageId>(
this is not coming through here:
buffer.write('SDK version ${cause.constraint}');

We could probably fix this

@mit-mit
Copy link
Member

mit-mit commented Jan 22, 2023

Yes, I think #3572 should not be in Dart 2.19. That was not intended. @sigurdm can you start a cherry-pick?

@renatoathaydes
Copy link

I think this is breaking my package score in pub.dev: https://pub.dev/packages/isolate_current_directory/score

SLVR: fact: isolate_current_directory requires SDK version >=2.19.0 <4.0.0
SLVR: conflict: isolate_current_directory requires SDK version >=2.19.0 <4.0.0
SLVR: Version solving took 0:00:00.029009 seconds.
    | Tried 1 solutions.
FINE: Resolving dependencies finished (0.058s).
ERR : The current Dart SDK version is 2.19.0-444.4.beta.
    | 
    | Because isolate_current_directory requires SDK version >=2.19.0 <4.0.0

My pubspec says:

environment:
  sdk: '>=2.19.0 <3.0.0'

@renatoathaydes
Copy link

Or maybe pub.dev's score system needs to upgrade its Dart SDK given it seems to be behind?

@mit-mit
Copy link
Member

mit-mit commented Jan 25, 2023

@renatoathaydes I think this was fixed? I'm seeing 130/140 points on my end...

@renatoathaydes
Copy link

@mit-mit ah great, they probably updated the Dart SDK, it was failing lots of things before!

@BaudouinCS
Copy link

I'm getting a

This requires the 'records' language feature to be enabled.
Try updating your pubspec.yaml to set the minimum SDK constraint to 2.19.0 or higher, and running 'pub get'.

My pubspec.yaml, post-flutter pub get:

environment:
  sdk: ">=2.19.0 <3.0.2"

Is this linked to this issue?

@mit-mit
Copy link
Member

mit-mit commented Feb 9, 2023

That is unrelated -- it looks like you are previewing the upcoming records feature? In that case you need the lower constraint to be >=2.19.0 AND pass the records experiment flag as the feature still hasn't graduated to beta and thus is still behind a flag.

@sigurdm
Copy link
Contributor

sigurdm commented Feb 14, 2023

Closing, as this has landed in a stable hotfix.

@sigurdm sigurdm closed this as completed Feb 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants