r-lib / pkgdepends

R Package Dependency Resolution
https://r-lib.github.io/pkgdepends/
Other
102 stars 30 forks source link

Solver warnings with versioned CRAN package references #309

Closed pawelru closed 1 year ago

pawelru commented 1 year ago

So after https://github.com/r-lib/pkgdepends/pull/308 versioned CRAN package references are supported and I got solver warnings that results in failed dependency resolution

reprex:

temp_desc <- desc::desc("!new")
temp_desc$set_dep("knitr", "Imports")
temp_desc$set_dep("withr", "Imports")
temp_desc$set_remotes(c(
    "knitr@1.34", 
    "withr@2.4.3"
))
temp_desc_path <- tempfile()
temp_desc$write(temp_desc_path)
x <- pkgdepends::new_pkg_deps(temp_desc_path, config = list(library = tempfile()))
x$solve()
x$get_solution()

warnings:

r$> x$solve()
Warning messages:
1: In value$ref %in% private$state$ref && !value$direct :
  'length(x) = 2 > 1' in coercion to 'logical(1)'
2: In value$ref %in% private$state$ref && !value$direct :
  'length(x) = 2 > 1' in coercion to 'logical(1)'
3: In value$ref %in% private$state$ref && !value$direct && private$state$direct[match(value$ref,  :
  'length(x) = 2 > 1' in coercion to 'logical(1)'

output:

r$> x$get_solution()
<pkg_solution>
+ result: FAILED
+ refs:
  - local::/var/folders/m1/hrz0h_ls7gz57rc80tnj41t80000gp/T//RtmpQo6eWm/file149f0aa9dff9
+ constraints (6):
  - `knitr@1.34` resolution failed
  - `withr@2.4.3` resolution failed
  - select {{ Package }} exactly once
  - select knitr at most once
  - local::/var/folders/m1/hrz0h_ls7gz57rc80tnj41t80000gp/T//RtmpQo6eWm/file149f0aa9dff9 depends on knitr@1.34: but not knitr@1.34 NA, withr@2.4.3 NA
  - local::/var/folders/m1/hrz0h_ls7gz57rc80tnj41t80000gp/T//RtmpQo6eWm/file149f0aa9dff9 depends on withr@2.4.3: but no candidates
x failures:
* local::/var/folders/m1/hrz0h_ls7gz57rc80tnj41t80000gp/T//RtmpQo6eWm/file149f0aa9dff9:
  * Can't install dependency knitr@1.34
  * Can't install dependency withr@2.4.3
* knitr@1.34: ! pkgdepends resolution error for .
Caused by error: 
! argument is of length zero
* withr@2.4.3: ! pkgdepends resolution error for .
Caused by error: 
! argument is of length zero

Things are correct if I use cran/<pkg>/<version> notation

temp_desc <- desc::desc("!new")
temp_desc$set_dep("knitr", "Imports")
temp_desc$set_dep("withr", "Imports")
temp_desc$set_remotes(c(
    "cran/knitr@1.34", 
    "cran/withr@2.4.3"
))
temp_desc_path <- tempfile()
temp_desc$write(temp_desc_path)
x <- pkgdepends::new_pkg_deps(temp_desc_path, config = list(library = tempfile()))
x$solve()
x$get_solution()

output:

r$> x$get_solution()
<pkg_solution>
+ result: OK
+ refs:
  - local::/var/folders/m1/hrz0h_ls7gz57rc80tnj41t80000gp/T//RtmpQo6eWm/file149f012f2c0a9
+ constraints (49):
  - select {{ Package }} exactly once
  - select knitr at most once
  - select withr at most once
  - select cli at most once
  - select evaluate at most once
  - select glue at most once
  - select highr at most once
  - select lifecycle at most once
  - select magrittr at most once
  - select rlang at most once
  ...
+ solution:
  - cli
  - cran/knitr@1.34
  - cran/withr@2.4.3
  - evaluate
  - glue
  - highr
  - lifecycle
  - local::/var/folders/m1/hrz0h_ls7gz57rc80tnj41t80000gp/T//RtmpQo6eWm/file149f012f2c0a9
  - magrittr
  - rlang
  - stringi
  - stringr
  - vctrs
  - xfun
  - yaml