r-lib / pkgdepends

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

Have a way to update only packages that have binaries available. #324

Open krlmlr opened 1 year ago

krlmlr commented 1 year ago

On 5471946.

Follow-up to https://github.com/r-lib/pak/issues/522.

library(pkgdepends)
dir.create(pkg <- tempfile())
dir.create(lib <- tempfile())
setwd(pkg)
Sys.setenv(PKG_PLATFORMS = current_r_platform())
writeLines("Package: foo\nVersion: 1.0.0\nImports: pillar\nRemotes: r-lib/pillar", "DESCRIPTION")
p <- new_pkg_installation_proposal("deps::.", config = list(library = lib))
p$solve()
#> ! Using bundled GitHub PAT. Please add your own PAT using `gitcreds::gitcreds_set()`.
#> ℹ Loading metadata database
#> ✔ Loading metadata database ... done
#> 
p$show_solution()
#> Error: ! Could not solve package dependencies:
#> * deps::.: Can't install dependency r-lib/pillar
#> * r-lib/pillar: Platform mismatch

Created on 2023-07-10 with reprex v2.0.2

Session info ``` r sessioninfo::session_info() #> ─ Session info ─────────────────────────────────────────────────────────────── #> setting value #> version R version 4.2.3 (2023-03-15) #> os macOS Ventura 13.4.1 #> system aarch64, darwin20 #> ui X11 #> language (EN) #> collate en_US.UTF-8 #> ctype en_US.UTF-8 #> tz Europe/Zurich #> date 2023-07-10 #> pandoc 3.1.3 @ /opt/homebrew/bin/ (via rmarkdown) #> #> ─ Packages ─────────────────────────────────────────────────────────────────── #> package * version date (UTC) lib source #> callr 3.7.3 2022-11-02 [1] CRAN (R 4.2.0) #> cli 3.6.1 2023-03-23 [1] CRAN (R 4.2.0) #> crayon 1.5.2 2022-09-29 [1] CRAN (R 4.2.0) #> curl 5.0.1 2023-06-07 [1] CRAN (R 4.2.0) #> debugme 1.1.0 2017-10-22 [1] CRAN (R 4.2.0) #> desc 1.4.2 2022-09-08 [1] CRAN (R 4.2.0) #> digest 0.6.33 2023-07-07 [1] CRAN (R 4.2.0) #> evaluate 0.21 2023-05-05 [1] CRAN (R 4.2.0) #> fansi 1.0.4 2023-01-22 [1] CRAN (R 4.2.0) #> fastmap 1.1.1 2023-02-24 [1] CRAN (R 4.2.0) #> filelock 1.0.2 2018-10-05 [1] CRAN (R 4.2.0) #> fs 1.6.2 2023-04-25 [1] CRAN (R 4.2.0) #> glue 1.6.2 2022-02-24 [1] CRAN (R 4.2.0) #> htmltools 0.5.5 2023-03-23 [1] CRAN (R 4.2.0) #> jsonlite 1.8.7 2023-06-29 [1] CRAN (R 4.2.0) #> knitr 1.43 2023-05-25 [1] CRAN (R 4.2.3) #> lifecycle 1.0.3 2022-10-07 [1] CRAN (R 4.2.0) #> lpSolve 5.6.18 2023-02-01 [1] CRAN (R 4.2.0) #> magrittr 2.0.3 2022-03-30 [1] CRAN (R 4.2.0) #> pillar 1.9.0 2023-03-22 [1] CRAN (R 4.2.0) #> pkgbuild 1.4.1 2023-06-14 [1] CRAN (R 4.2.3) #> pkgcache 2.1.1.9000 2023-07-10 [1] Github (r-lib/pkgcache@9612706) #> pkgdepends * 0.5.0.9001 2023-07-10 [1] Github (r-lib/pkgdepends@5471946) #> prettyunits 1.1.1 2020-01-24 [1] CRAN (R 4.2.0) #> processx 3.8.2 2023-06-30 [1] CRAN (R 4.2.0) #> ps 1.7.5 2023-04-18 [1] CRAN (R 4.2.0) #> purrr 1.0.1 2023-01-10 [1] CRAN (R 4.2.0) #> R.cache 0.16.0 2022-07-21 [1] CRAN (R 4.2.0) #> R.methodsS3 1.8.2 2022-06-13 [1] CRAN (R 4.2.0) #> R.oo 1.25.0 2022-06-12 [1] CRAN (R 4.2.0) #> R.utils 2.12.2 2022-11-11 [1] CRAN (R 4.2.0) #> R6 2.5.1 2021-08-19 [1] CRAN (R 4.2.0) #> rappdirs 0.3.3 2021-01-31 [1] CRAN (R 4.2.0) #> reprex 2.0.2 2022-08-17 [1] CRAN (R 4.2.0) #> rlang 1.1.1 2023-04-28 [1] CRAN (R 4.2.0) #> rmarkdown 2.23 2023-07-01 [1] CRAN (R 4.2.0) #> rprojroot 2.0.3 2022-04-02 [1] CRAN (R 4.2.0) #> rstudioapi 0.14 2022-08-22 [1] CRAN (R 4.2.0) #> sessioninfo 1.2.2 2021-12-06 [1] CRAN (R 4.2.0) #> styler 1.10.1 2023-06-05 [1] CRAN (R 4.2.0) #> utf8 1.2.3 2023-01-31 [1] CRAN (R 4.2.0) #> vctrs 0.6.3 2023-06-14 [1] CRAN (R 4.2.3) #> withr 2.5.0 2022-03-03 [1] CRAN (R 4.2.0) #> xfun 0.39 2023-04-20 [1] CRAN (R 4.2.0) #> yaml 2.3.7 2023-01-23 [1] CRAN (R 4.2.0) #> zip 2.3.0 2023-04-17 [1] CRAN (R 4.2.0) #> #> [1] /Users/kirill/Library/R/arm64/4.2/library #> [2] /Library/Frameworks/R.framework/Versions/4.2-arm64/Resources/library #> #> ────────────────────────────────────────────────────────────────────────────── ```
gaborcsardi commented 1 year ago

Yes, that would be an installation from source, and since only binaries are allowed, it fails. That seems right for me, although I understand that it is not very practical.

krlmlr commented 1 year ago

Thanks. Would you suppose the following to work then?

library(pkgdepends)
dir.create(pkg <- tempfile())
dir.create(lib <- tempfile())
setwd(pkg)
Sys.setenv(PKG_PLATFORMS = current_r_platform())
writeLines("Package: foo\nVersion: 1.0.0\nImports: pillar\nRemotes: pillar=github::r-lib/pillar?source", "DESCRIPTION")
p <- new_pkg_installation_proposal("deps::.", config = list(library = lib))
p$solve()
#> ℹ Loading metadata database
#> ✔ Loading metadata database ... done
#> 
p$show_solution()
#> Error: ! Could not solve package dependencies:
#> * deps::.: Can't install dependency pillar=github::r-lib/pillar?source

Created on 2023-07-10 with reprex v2.0.2

Session info ``` r sessioninfo::session_info() #> ─ Session info ─────────────────────────────────────────────────────────────── #> setting value #> version R version 4.2.3 (2023-03-15) #> os macOS Ventura 13.4.1 #> system aarch64, darwin20 #> ui X11 #> language (EN) #> collate en_US.UTF-8 #> ctype en_US.UTF-8 #> tz Europe/Zurich #> date 2023-07-10 #> pandoc 3.1.3 @ /opt/homebrew/bin/ (via rmarkdown) #> #> ─ Packages ─────────────────────────────────────────────────────────────────── #> package * version date (UTC) lib source #> callr 3.7.3 2022-11-02 [1] CRAN (R 4.2.0) #> cli 3.6.1 2023-03-23 [1] CRAN (R 4.2.0) #> crayon 1.5.2 2022-09-29 [1] CRAN (R 4.2.0) #> curl 5.0.1 2023-06-07 [1] CRAN (R 4.2.0) #> debugme 1.1.0 2017-10-22 [1] CRAN (R 4.2.0) #> desc 1.4.2 2022-09-08 [1] CRAN (R 4.2.0) #> digest 0.6.33 2023-07-07 [1] CRAN (R 4.2.0) #> evaluate 0.21 2023-05-05 [1] CRAN (R 4.2.0) #> fansi 1.0.4 2023-01-22 [1] CRAN (R 4.2.0) #> fastmap 1.1.1 2023-02-24 [1] CRAN (R 4.2.0) #> filelock 1.0.2 2018-10-05 [1] CRAN (R 4.2.0) #> fs 1.6.2 2023-04-25 [1] CRAN (R 4.2.0) #> glue 1.6.2 2022-02-24 [1] CRAN (R 4.2.0) #> htmltools 0.5.5 2023-03-23 [1] CRAN (R 4.2.0) #> jsonlite 1.8.7 2023-06-29 [1] CRAN (R 4.2.0) #> knitr 1.43 2023-05-25 [1] CRAN (R 4.2.3) #> lifecycle 1.0.3 2022-10-07 [1] CRAN (R 4.2.0) #> lpSolve 5.6.18 2023-02-01 [1] CRAN (R 4.2.0) #> magrittr 2.0.3 2022-03-30 [1] CRAN (R 4.2.0) #> pillar 1.9.0 2023-03-22 [1] CRAN (R 4.2.0) #> pkgbuild 1.4.1 2023-06-14 [1] CRAN (R 4.2.3) #> pkgcache 2.1.1.9000 2023-07-10 [1] Github (r-lib/pkgcache@9612706) #> pkgdepends * 0.5.0.9001 2023-07-10 [1] Github (r-lib/pkgdepends@5471946) #> prettyunits 1.1.1 2020-01-24 [1] CRAN (R 4.2.0) #> processx 3.8.2 2023-06-30 [1] CRAN (R 4.2.0) #> ps 1.7.5 2023-04-18 [1] CRAN (R 4.2.0) #> purrr 1.0.1 2023-01-10 [1] CRAN (R 4.2.0) #> R.cache 0.16.0 2022-07-21 [1] CRAN (R 4.2.0) #> R.methodsS3 1.8.2 2022-06-13 [1] CRAN (R 4.2.0) #> R.oo 1.25.0 2022-06-12 [1] CRAN (R 4.2.0) #> R.utils 2.12.2 2022-11-11 [1] CRAN (R 4.2.0) #> R6 2.5.1 2021-08-19 [1] CRAN (R 4.2.0) #> rappdirs 0.3.3 2021-01-31 [1] CRAN (R 4.2.0) #> reprex 2.0.2 2022-08-17 [1] CRAN (R 4.2.0) #> rlang 1.1.1 2023-04-28 [1] CRAN (R 4.2.0) #> rmarkdown 2.23 2023-07-01 [1] CRAN (R 4.2.0) #> rprojroot 2.0.3 2022-04-02 [1] CRAN (R 4.2.0) #> rstudioapi 0.15.0 2023-07-07 [1] CRAN (R 4.2.0) #> sessioninfo 1.2.2 2021-12-06 [1] CRAN (R 4.2.0) #> styler 1.10.1 2023-06-05 [1] CRAN (R 4.2.0) #> utf8 1.2.3 2023-01-31 [1] CRAN (R 4.2.0) #> vctrs 0.6.3 2023-06-14 [1] CRAN (R 4.2.3) #> withr 2.5.0 2022-03-03 [1] CRAN (R 4.2.0) #> xfun 0.39 2023-04-20 [1] CRAN (R 4.2.0) #> yaml 2.3.7 2023-01-23 [1] CRAN (R 4.2.0) #> zip 2.3.0 2023-04-17 [1] CRAN (R 4.2.0) #> #> [1] /Users/kirill/Library/R/arm64/4.2/library #> [2] /Library/Frameworks/R.framework/Versions/4.2-arm64/Resources/library #> #> ────────────────────────────────────────────────────────────────────────────── ```
gaborcsardi commented 1 year ago

It should, but ? parameters don't yet work from Remotes and other package fields.

krlmlr commented 1 year ago

Should pkgdepends have a notion of source-only package sources where the PKG_PLATFORMS env var is ignored?

I'm trying to find a way to use pak to always install whatever latest version is available in binary form from CRAN, without compromising GitHub and other installs.

gaborcsardi commented 1 year ago

That's what pak does by default if you set upgrade=FALSE.

krlmlr commented 1 year ago

Fair enough. But consider the following example in one of my projects:

d> pak::pak()
→ Will update 2 packages.
→ Will download 1 CRAN package (4.29 MB), cached: 2 (2.06 MB).
+ Matrix 1.5-4.1 → 1.6-0   👷🏾‍♂️🔧
+ shiny  1.7.4   → 1.7.4.1  ⬇ (4.29 MB)
? Do you want to continue (Y/n) n

d> pak::pak(upgrade = FALSE)
→ The package (0 B) is cached.
ℹ No downloads are needed
✔ 134 deps: kept 132 [1.7s]

How can I upgrade shiny but not Matrix?

gaborcsardi commented 1 year ago

Yeah, it would be nice to have an easy way to update the packages that have binaries available.