dart-lang / pub

The pub command line tool
https://dart.dev/tools/pub/cmd
BSD 3-Clause "New" or "Revised" License
1.04k stars 228 forks source link

Pub Update should not download packages incompatible with the current SDK #481

Closed DartBot closed 9 years ago

DartBot commented 9 years ago

Issue by rbishop-bah Originally opened as dart-lang/sdk#9216


For projects with builds that always update to the latest packages, it'd be nice if staggered releases of packages and the SDK did not cause build failures. We currently have a situation where a number of pub packages have been updated for the impending release of 0.4.2.x, but the SDK itself has not been released. I'm wondering why pub update isn't smart enough to forego a package update when it knows it won't work (i.e., package, such as web_ui declares in its pubspec.yaml:

environment:   sdk: ">=0.4.2+0.r20084"

but pub update grabs it anyway, even though it knows I'm using SDK 19045... see output below).

What steps will reproduce the problem?

  1. Run pub update on an existing project that had been compiling fine, that has dependencies on packages in pub that have updated versions that depend on an unreleased SDK version.

What is the expected output? What do you see instead? I expect pub not to download packages that are incompatible with the current SDK (or at least that should be the default with an option to force). I see build carnage instead.

What version of the product are you using? On what operating system? Windows64 and Linux64

Please provide any additional information below. Sample message: Resolving dependencies... Dependencies updated! Some packages that were installed are not compatible with your SDK version 0.4.1+0.r19425 and may not work:

You may be able to resolve this by upgrading to the latest Dart SDK or adding a version constraint to use an older version of a package.

DartBot commented 9 years ago

Comment by amouravski


Perhaps a dependency constraint like "any compatible" or "latest compatible" would help.

DartBot commented 9 years ago

Comment by kasperl


Added Area-Pub, Triaged labels.

DartBot commented 9 years ago

Comment by munificent


I'm wondering why pub update isn't smart enough to forego a package update when it knows it won't work

It is because pub's constraint solver literally isn't smart enough to solve that. The current implementation is very simple and doesn't do any backtracking when exploring the solution space. In order to correctly select the right version of a package while taking SDK constraints into account, it will need to backtrack in order to find a solution to even just-barely-more-complex-than-trivial dependency graphs.

Perhaps a dependency constraint like "any compatible" or "latest compatible" would help.

Packages can and do specify the SDK constraints. It's just that pub can't currently solve them.

We do expect to implement a more complex solver at some point (other package managers always seem to eventually end up adding backtracking), so I'll leave this bug open for that.

We know the current behavior isn't ideal, but it was the best we could get implemented in a short timeframe. We felt the warnings were better than nothing given that every release of the SDK right now is a breaking one.


Set owner to @munificent. Removed Type-Defect label. Added Type-Enhancement label.

DartBot commented 9 years ago

Comment by munificent


Added this to the M4 milestone. Added Started label.

DartBot commented 9 years ago

Comment by munificent


Removed this from the M4 milestone. Added this to the M5 milestone.

DartBot commented 9 years ago

Comment by munificent


Marked this as blocking #474.

DartBot commented 9 years ago

Comment by munificent


https://codereview.chromium.org/14232023/


Added Fixed label.