Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pkg_deps gets wrong dependencies (for past versions) #663

Open
eliotmcintire opened this issue Jul 15, 2024 · 4 comments
Open

pkg_deps gets wrong dependencies (for past versions) #663

eliotmcintire opened this issue Jul 15, 2024 · 4 comments

Comments

@eliotmcintire
Copy link

Struggling with several issues in pak recently. This one seems like a simple bug to recreate. The code below requests specific versions of the package BalancedSampling. It shows Rcpp has a minimum version, which appears to be incorrect based on the DESCRIPTION file in the respective archives. The version 1.6.3 does not have Rcpp >= 1.0.12 but pkg_dep says it does.

library(dplyr)

# reprex
pkg <- "BalancedSampling"
ver1 <- "1.6.3"
ver2 <- "2.0.5"

# empty lists to fill
deps <- list()
pakVers <- list()
manual <- list()

deps[[ver1]] <- pak::pkg_deps(paste0(pkg, "@", ver1))
deps[[ver2]] <- pak::pkg_deps(paste0(pkg, "@", ver2))

# pkg_dep gives them the same minimum requirement for ver1 and ver2
pakVers[[ver1]] <- deps[[ver1]] |> filter(ref == "Rcpp") |> select(version) # 1.0.12
pakVers[[ver2]] <- deps[[ver2]] |> filter(ref == "Rcpp") |> select(version) # 1.0.12

# Check with manual downloads
# The two have different minimum requirements for Rcpp

# ver1
setwd(tempdir())
tf <- tempfile(".tar.gz")
fl <- file.path(pkg, "DESCRIPTION")
download.file(file.path(contrib.url(getOption("repos")), 
                        "Archive", pkg, paste0(pkg, "_", ver1, ".tar.gz")), destfile = tf)
untar(tf, files = fl)
manual[[ver1]] <- utils::packageDescription(pkg, lib.loc = ".", field = c("Imports"))

# Check with manual download for ver2
setwd(tempdir())
tf <- tempfile(".tar.gz")
fl <- file.path(pkg, "DESCRIPTION")
download.file(file.path(contrib.url(getOption("repos")), 
                        "Archive", pkg, paste0(pkg, "_", ver2, ".tar.gz")), destfile = tf)
untar(tf, files = fl)
manual[[ver2]] <- utils::packageDescription(pkg, lib.loc = ".", field = c("Imports"))

manual # ver1 has 0.11.1; ver2 has 1.0.12
pakVers   # ver1 has 1.0.12; ver2 has 1.0.12
@gaborcsardi
Copy link
Member

Seems correct to me:

pak::pkg_deps("[email protected]")
# A data frame: 3 × 32
  ref     type  direct directpkg status package version license needscompilation
  <chr>   <chr> <lgl>  <lgl>     <chr>  <chr>   <chr>   <chr>   <lgl>
1 BalancstanTRUE   TRUE      OK     Balanc1.6.3   GPL (>TRUE
2 Rcpp    stanFALSE  FALSE     OK     Rcpp    1.0.12  GPL (>FALSE
3 SamplistanFALSE  FALSE     OK     Sampli1.0.0   GPL (>FALSE
# ℹ 23 more variables: priority <chr>, md5sum <chr>, sha256 <chr>,
#   filesize <int>, built <chr>, platform <chr>, rversion <chr>,
#   repotype <chr>, repodir <chr>, target <chr>, deps <list>, mirror <chr>,
#   sources <list>, remote <list>, error <list>, metadata <list>,
#   dep_types <list>, params <list>, sysreqs <chr>, cache_status <chr>,
#   lib_status <chr>, old_version <chr>, new_version <chr>
pak::pkg_deps("[email protected]")$deps[[1]]
# A data frame: 3 × 5
  ref             type      package         op    version
  <chr>           <chr>     <chr>           <chr> <chr>
1 Rcpp            Imports   Rcpp            ">="  "0.11.1"
2 SamplingBigData Imports   SamplingBigData ""    ""
3 Rcpp            LinkingTo Rcpp            ""    ""

@gaborcsardi
Copy link
Member

gaborcsardi commented Jul 15, 2024

# pkg_dep gives them the same minimum requirement for ver1 and ver2

That's not a minimum requirement, pkg_deps() simply resolves all dependencies and lists them in a data frame. It uses the latest versions of the dependencies as much as possible, by default.

@eliotmcintire
Copy link
Author

So, the reported version in the column labelled "version" in the returned data.frame is not the required version, it is the "current" version?

The documentation is ambiguous about this:

A data frame with the dependency data
... 
version: package version

Why would it return "dependency data" in the version column that is different than the deps column?

@gaborcsardi
Copy link
Member

pkg_deps() looks up the dependencies of a package and returns data about them. It basically does the same as pkg_install(), but stops before the installation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants