pkgdepends icon indicating copy to clipboard operation
pkgdepends copied to clipboard

Handling of package dependency constraints ==, <= and <

Open martinstuder opened this issue 5 years ago • 4 comments

This is a follow-up of https://github.com/r-lib/remotes/issues/376 after having been referred to pak and as such indirectly also pkgdepends.

I'm considering the following "artificial" package testdeps:

Type: Package
Package: testdeps
Title: Handling Package Dependency Specification
Version: 0.0.1
Authors@R: person("Martin", "Studer", "[email protected]", c("aut", "cre"))
Description: Testing handling of package dependency specifications.
License: MIT
Imports: 
    abind,
    biogas (>= 1.9.0),
    coop (> 0.4-0),
    deal (== 1.2-35),
    effsize (<= 0.7.0),
    face (< 0.1-4)

I have an environment established as follows:

install.packages("devtools")
devtools::install_github("r-lib/pkgdepends")

dir.create("libdir1")
.libPaths(c("libdir1", .libPaths()))

remotes::install_version("biogas", "1.8.0")
remotes::install_version("coop", "0.4-0")
remotes::install_version("deal", "1.2-37")
remotes::install_version("effsize", "0.7.1")
remotes::install_version("face", "0.1-5")

dir.create("libdir2")
.libPaths(c("libdir2", .libPaths()))
  • A .libPaths() in the order libdir2, libdir1, ...
  • libdir1 contains some of the package dependencies but with versions not matching the constraints of testdeps - of special interest are the dependencies deal, effsize and face which use dependency constraints ==, <= and <
  • libdir2 is an empty library directory at the top of .libPaths()

I now use pkgdepends to attempt to solve the dependencies for testdeps in the following way:

r <- pkgdepends::remotes()$new("deps::.", library = .libPaths()[1])
r$solve(policy = "lazy")
  • above DESCRIPTION file present in current working directory
  • using .libPaths()[1], i.e. libdir2 as the library directory

This results in the following output:

ℹ Checking for package metadata updates
✔ All 6 metadata files are current.                                             
✔ Loading session disk cached package metadata                                  
✔ Using cached package metadata                                                 
PKG FAILED SOLUTION, 0 refs, resolved in 85ms, solved in 19ms ─────────────────
  * Cannot install `deps::.`.
    - Cannot install dependency deal
  * Cannot install `deps::.`.
    - Cannot install dependency effsize
  * Cannot install `deps::.`.
    - Cannot install dependency face

I would have expected this to give a solution since libdir2 is empty and it is theoretically possible for deal, effsize and face to be installed with appropriate versions without affecting any existing installations of those packages (which are installed in libdir1). A failure seems reasonable if package installation would result in loss of existing installations but that's not the case in this example.

martinstuder avatar Jun 04 '19 19:06 martinstuder

Where is the testdeps package?

gaborcsardi avatar Jun 04 '19 20:06 gaborcsardi

I just built a DESCRIPTION for illustration purposes. I basically just have a folder with that file.

martinstuder avatar Jun 04 '19 20:06 martinstuder

I have the same problem for a number of internal packages, that I'm testing out with pkgdepends. We're using hard version dependencies (== and =>), and pgkdepends seems to give incorrect resolution errors.

johanneswaage avatar Jan 13 '21 13:01 johanneswaage

We cannot properly implement this for CRAN (and Bioconductor) packages currently, because their metadata does not contain information about older package versions. To gather all the metadata from the package files in the CRAN archive is very tedious currently. E.g. for something like effsize (<= 0.7.0) we would need to download all previous versions of the package to look up their dependencies.

gaborcsardi avatar Mar 08 '21 12:03 gaborcsardi