r-lib / pak

A fresh approach to package installation
https://pak.r-lib.org
643 stars 56 forks source link

Dependency resolution fails with more than one git Remote #525

Closed klmr closed 11 months ago

klmr commented 11 months ago

When a package description contains more than a single git:: Remote, ‘pak’ dependency resolution fails with an error and the package fails to install.

To clarify, this works:

Imports: rdep1
Remotes: git::https://github.com/klmr/rdep1.git

And this fails:

Imports: rdep1, rdep2
Remotes: git::https://github.com/klmr/rdep1.git, git::https://github.com/klmr/rdep2.git

I’ve created minimal example packages (klmr/rpkg, klmr/rdep1 & klmr/rdep2) to illustrate this:

> pak::pkg_deps('klmr/rpkg@single-dep')
! Using bundled GitHub PAT. Please add your own PAT using `gitcreds::gitcreds_set()`.
# A data frame: 2 × 32
  ref     type  direct directpkg status package version license needscompilation
  <chr>   <chr> <lgl>  <lgl>     <chr>  <chr>   <chr>   <chr>   <lgl>
1 klmr/r… gith… TRUE   TRUE      OK     rpkg    0.0.1   GPL (>… TRUE
2 git::h… git   FALSE  FALSE     OK     rdep1   0.0.1   GPL (>… TRUE
…

> pak::pkg_deps('klmr/rpkg@multi-deps')
Error:
! error in pak subprocess
Caused by error:
! Could not solve package dependencies:
* klmr/rpkg@multi-deps: ! pkgdepends resolution error for klmr/rpkg@multi-deps.
Caused by error:
! the condition has length > 1

Interestingly, I can’t reproduce this when manually resolving dependencies using ‘pkgdepends’ (0.6.0):

> multi_deps = pkgdepends::pkg_deps$new('klmr/rpkg@multi-deps')

> multi_deps$solve()

> multi_deps$stop_for_solution_error()

> multi_deps$get_solutIon()$data
# A data frame: 3 × 33
  ref     type  direct directpkg status package version license needscompilation
  <chr>   <chr> <lgl>  <lgl>     <chr>  <chr>   <chr>   <chr>   <lgl>
1 klmr/r… gith… TRUE   TRUE      OK     rpkg    0.0.1   GPL (>… TRUE
2 git::h… git   FALSE  FALSE     OK     rdep1   0.0.1   GPL (>… TRUE
3 git::h… git   FALSE  FALSE     OK     rdep2   0.0.1   GPL (>… TRUE
…
sessionInfo() ``` R version 4.2.0 (2022-04-22) Platform: x86_64-pc-linux-gnu (64-bit) Running under: Red Hat Enterprise Linux 8.6 (Ootpa) Matrix products: default BLAS/LAPACK: /apps/rocs/2020.08/cascadelake/software/OpenBLAS/0.3.9-GCC-9.3.0/lib/libopenblas_skylakexp-r0.3.9.so locale: [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C [3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8 [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 [7] LC_PAPER=en_US.UTF-8 LC_NAME=C [9] LC_ADDRESS=C LC_TELEPHONE=C [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C attached base packages: [1] stats graphics grDevices utils datasets methods base loaded via a namespace (and not attached): [1] rstudioapi_0.14 rappdirs_0.3.3 debugme_1.1.0 [4] R6_2.5.1 rlang_1.1.1 fansi_1.0.4 [7] tools_4.2.0 pak_0.5.1 pkgbuild_1.4.2 [10] lpSolve_5.6.18 pkgcache_2.2.0.1 utf8_1.2.3 [13] cli_3.6.1 rprojroot_2.0.3 lifecycle_1.0.3 [16] crayon_1.5.2 processx_3.5.3 zip_2.3.0 [19] BiocManager_1.30.17 callr_3.7.0 vctrs_0.6.2 [22] ps_1.7.0 curl_5.0.1 glue_1.6.2 [25] compiler_4.2.0 pillar_1.9.0 desc_1.4.2 [28] filelock_1.0.2 pkgdepends_0.6.0 prettyunits_1.1.1 [31] jsonlite_1.8.5 ```
klmr commented 11 months ago

Ah, a colleague just found r-lib/pkgdepends#318, which is probably related / solves this upstream.

klmr commented 11 months ago

Nightly build pak 0.5.1.9000 fixes the issue.