Open maximveksler opened 1 year ago
In general we don't expect the solver to give the best solution, only a solution with the heuristic of trying the newest version of a package first.
The issue here however seems that there is an actual incompatibility in the transitive dependencies, and dart pub add
is trying its best to avoid unlocking locked dependencies.
If you add firebase_core first, it resolves with firebase_core 2.3.0 -> firebase_core_web 2.0.1 -> flutter_web_plugins (from sdk) -> js 0.6.4 So because the flutter_web_plugins sdk package is pinned to js. v. 0.6.4 you get that as a transitive dependency.
However if you add mocktail first you get you mocktail 0.3.0 -> test 1.21.4 -> package:js v. 0.6.5. Because you didn't need the sdk package flutter_web_plugins you avoid the pinned package js.
flutter pub add
will try find a solution for firebase_core without unlocking current packages, and because firebase_core v. 0.4.2+2 doesn't have the transitive dependency on the flutter_web_plugins package that is what you get.
This is both confusing and unfortunate - but unlocking and downgrading transitive dependencies in pub add
is also surprising behaviour.
@jonasfj do you have some good ideas here?
There might be something we can do to at least explain better why a specific version cannot be obtained, but the best UI here is still a bit unclear to me. Maybe something along the lines of https://github.com/dart-lang/pub/pull/3569 but expanded to the case of successful pub add
and pub upgrade
where you did not get the newest version.
@sigurdm thanks for explaining the logic, yes I see where the root casue is.
This is both confusing and unfortunate - but unlocking and downgrading transitive dependencies in pub add is also surprising behaviour.
No, I'd say that if unlocking and downgrading a patch (or even a minor) of a transitive dependency results in major for the direct dependecy being added than it should weight more to tip the solver towards that case. From my perspective seems like a logic bug.
In addition please note that running flutter pub upgrade
will still not fix the issue.
However applying flutter pub upgrade --major-versions
does result in firebase_core: ^2.4.0
Environment
dart --version
): Dart SDK version: 2.18.5 (stable) (Tue Nov 22 15:47:29 2022 +0000) on "linux_x64"Linux m-inspiron5567 5.15.0-56-generic #62-Ubuntu SMP Tue Nov 22 19:54:14 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
Flutter Environment:
Problem
Bug
Running the following sequence of events would install
firebase_core: ^0.4.2+2
Works
Running the following sequence of events would install
firebase_core: ^2.3.0
Debug
Attached bug & works directories (with the verbose logs) for reference.
Expected behavior
The SLVR would produce the same package dependency graph, picking the lastest stable of each dependency.
Actual behavior
The SLVR picks the lowest possible version of firebase_core.