Is Pkg's dependency resolution order-dependent?

Here is an example where Pkg.adding first Cairo, then ImageView fails, whereas adding ImageView first works flawlessly.

  • Is it expected that the dependency resolution depends on the order in which packages are added?
  • In this specific case, is Pkg unable to detect that downgrading Cairo to an earlier version allows satisfying all dependency requirements, or is there some rule preventing Pkg from downgrading Cairo once it’s installed?


Steps to reproduce:

# Start with a fresh depot
shell> rm -rf /tmp/julia_depot
shell> mkdir /tmp/julia_depot
shell> export JULIA_DEPOT_PATH=/tmp/julia_depot

# Start with a new project
shell> rm -rf /tmp/project
shell> mkdir /tmp/project
shell> cd /tmp/project

shell> julia -q
(v1.2) pkg> activate .
Activating new environment at `/tmp/project/Project.toml`

(project) pkg> add Cairo
   Cloning default registries into `/tmp/julia_depot`
   Cloning registry from "https://github.com/JuliaRegistries/General.git"
     Added registry `General` to `/tmp/julia_depot/registries/General`
 Resolving package versions...
 Installed Cairo ───────────── v0.8.0
 [...]

(project) pkg> add ImageView
 Resolving package versions...
ERROR: Unsatisfiable requirements detected for package Gtk [4c0ca9eb]:
 Gtk [4c0ca9eb] log:
 ├─possible versions are: [0.16.0-0.16.5, 0.17.0, 0.18.0] or uninstalled
 ├─restricted by compatibility requirements with Cairo [159f3aea] to versions: uninstalled
 │ └─Cairo [159f3aea] log:
 │   ├─possible versions are: [0.5.3-0.5.6, 0.6.0, 0.7.0, 0.8.0] or uninstalled
 │   └─restricted to versions 0.8.0 by an explicit requirement, leaving only versions 0.8.0
 └─restricted by compatibility requirements with ImageView [86fae568] to versions: [0.16.0-0.16.5, 0.17.0, 0.18.0] — no versions left
   └─ImageView [86fae568] log:
     ├─possible versions are: [0.8.0-0.8.2, 0.9.0] or uninstalled
     ├─restricted to versions * by an explicit requirement, leaving only versions [0.8.0-0.8.2, 0.9.0]
     └─restricted by compatibility requirements with Cairo [159f3aea] to versions: 0.9.0 or uninstalled, leaving only versions: 0.9.0
       └─Cairo [159f3aea] log: see above

whereas:

# Start with a fresh depot
shell> rm -rf /tmp/julia_depot
shell> mkdir /tmp/julia_depot
shell> export JULIA_DEPOT_PATH=/tmp/julia_depot

# Start with a fresh project
shell> rm -rf /tmp/project
shell> mkdir /tmp/project
shell> cd /tmp/project

shell> julia -q
(v1.2) pkg> activate .
Activating new environment at `/tmp/project/Project.toml`

(project) pkg> add ImageView
   Cloning default registries into `/tmp/julia_depot`
   Cloning registry from "https://github.com/JuliaRegistries/General.git"
     Added registry `General` to `/tmp/julia_depot/registries/General`
 Resolving package versions...
 Installed ImageView ───────────────── v0.9.0
 Installed Cairo ───────────────────── v0.6.0
 [...]

(project) pkg> add Cairo
 Resolving package versions...
  Updating `/tmp/project/Project.toml`
  [159f3aea] + Cairo v0.6.0
  Updating `/tmp/project/Manifest.toml`
 [no changes]
1 Like

The answer to the question of order dependency is yes, it matters. The reason is that Pkg doesn’t want to change the version of installed packages on add.

However, this was determined to be quite confusing so in 1.4 there is a different strategy in place which should reduce the number of resolver errors by allowing current installed versions to change on add if they need to.

6 Likes

Thanks!