Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why pub upgrade don't upgrade packages and just show them

Tags:

dart

dart-pub

I've got:

>pub upgrade
Resolving dependencies... (6.2s)
  analyzer 0.18.0 (9 newer versions available)
  angular 0.14.0
  args 0.10.0+2 (5 newer versions available)
  barback 0.13.0 (14 newer versions available)
  bootjack 0.6.5+2
  browser 0.10.0+2
  code_transformers 0.1.6 (5 newer versions available)
  collection 0.9.4 (1 newer version available)
  di 2.0.2 (3 newer versions available)
  dquery 0.7.0+4
  html5lib 0.10.0 (4 newer versions available)
  intl 0.11.9
  logging 0.9.1+1 (2 newer versions available)
  path 1.3.0
  perf_api 0.0.9
  petitparser 1.2.2
  route_hierarchical 0.4.22 (1 newer version available)
  shadow_dom 0.10.0
  source_maps 0.9.4 (1 newer version available)
  source_span 1.0.0
  stack_trace 0.9.3+2 (6 newer versions available)
  typed_mock 0.0.4
  utf 0.9.0+1

so I can see that newer versions available but so how to update them?

like image 656
cnd Avatar asked Oct 11 '25 23:10

cnd


1 Answers

A direct or transitive dependency has a version constraint that doesn't allow to use a newer version.

In Dart a package can only be imported in one version.
All dependencies need to agree on one version.

As far as I know in Java a package A can import package B version 1.0 and package C even when package C imports B in version 2.0.
This is not possible in Dart, the entire application has to use the same version of B.

To find out what prevents the upgrade I usually add a constraint in my pubspec.yaml that enforces the newer version.
Running pub upgrade then shows which dependency prevents the upgrade.

add a dependency constraint

dependencies:
  html5lib: '>= 0.10.0'<

run

pub upgrade

inspect the result

This usually takes several iterations until the culprit can be figured out.

pub deps -s list

shows a helpful overview of all dependencies and constraints

You can also add a dependency_overrides to your pubspec.yaml.

dependency_overrides:
  html5lib: '>= 0.10.0'

to just enforce the newer version and ignore possible incompatibilities.
(http://pub.dartlang.org doesn't allow to upload packages that contain dependency_overrides.)

like image 53
Günter Zöchbauer Avatar answered Oct 14 '25 16:10

Günter Zöchbauer



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!