r-lib / pak

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

pkg_sysreqs() does not support Ubuntu derivates such as Mint #592

Closed florisvdh closed 7 months ago

florisvdh commented 7 months ago

Linux Mint uses the Ubuntu LTS repositories and inherits much of its structure. As a consequence Ubuntu workflows practically always work in Linux Mint, including R2U etc etc, by providing the underlying Ubuntu version as needed in the definition of software repositories. This compatibility is intentional.

I encountered following problem however:

library(pak)
pkg_sysreqs("spsurvey")
#> ℹ Loading metadata database
#> ✔ Loading metadata database ... done
#> 
#> Error: ! error in pak subprocess
#> Caused by error in `sysreqs2_command(sysreqs_platform, "update")`:
#> ! Unknown OS. Don't know how to query or install system packages for
#> x86_64-pc-linux-gnu-linuxmint-21.3.
system_r_platform_data()
#>      cpu vendor        os distribution release
#> 1 x86_64     pc linux-gnu    linuxmint    21.3
#>                             platform
#> 1 x86_64-pc-linux-gnu-linuxmint-21.3

Created on 2024-02-14 with reprex v2.1.0

Session info ``` r sessioninfo::session_info() #> ─ Session info ─────────────────────────────────────────────────────────────── #> setting value #> version R version 4.3.2 (2023-10-31) #> os Linux Mint 21.3 #> system x86_64, linux-gnu #> ui X11 #> language nl_BE:nl #> collate nl_BE.UTF-8 #> ctype nl_BE.UTF-8 #> tz Europe/Brussels #> date 2024-02-14 #> pandoc 3.1.1 @ /usr/lib/rstudio/resources/app/bin/quarto/bin/tools/ (via rmarkdown) #> #> ─ Packages ─────────────────────────────────────────────────────────────────── #> package * version date (UTC) lib source #> callr 3.7.3 2022-11-02 [3] RSPM (R 4.2.0) #> cli 3.6.2 2023-12-11 [3] RSPM (R 4.3.0) #> digest 0.6.34 2024-01-11 [3] RSPM (R 4.3.0) #> evaluate 0.23 2023-11-01 [3] RSPM (R 4.3.0) #> fansi 1.0.6 2023-12-08 [3] RSPM (R 4.3.0) #> fastmap 1.1.1 2023-02-24 [3] RSPM (R 4.2.0) #> fs 1.6.3 2023-07-20 [3] RSPM (R 4.2.0) #> glue 1.7.0 2024-01-09 [3] RSPM (R 4.3.0) #> htmltools 0.5.7 2023-11-03 [3] RSPM (R 4.3.0) #> knitr 1.45 2023-10-30 [3] RSPM (R 4.3.0) #> lifecycle 1.0.4 2023-11-07 [3] RSPM (R 4.3.0) #> magrittr 2.0.3 2022-03-30 [3] RSPM (R 4.2.0) #> pak * 0.7.1 2023-12-11 [3] RSPM (R 4.3.0) #> pillar 1.9.0 2023-03-22 [3] RSPM (R 4.2.0) #> processx 3.8.3 2023-12-10 [3] RSPM (R 4.3.0) #> ps 1.7.6 2024-01-18 [3] RSPM (R 4.3.0) #> purrr 1.0.2 2023-08-10 [3] RSPM (R 4.2.0) #> R.cache 0.16.0 2022-07-21 [3] RSPM (R 4.2.0) #> R.methodsS3 1.8.2 2022-06-13 [3] RSPM (R 4.2.0) #> R.oo 1.26.0 2024-01-24 [3] RSPM (R 4.3.0) #> R.utils 2.12.3 2023-11-18 [3] RSPM (R 4.3.0) #> R6 2.5.1 2021-08-19 [3] RSPM (R 4.2.0) #> reprex 2.1.0 2024-01-11 [3] RSPM (R 4.3.0) #> rlang 1.1.3 2024-01-10 [3] RSPM (R 4.3.0) #> rmarkdown 2.25 2023-09-18 [3] RSPM (R 4.3.0) #> rstudioapi 0.15.0 2023-07-07 [3] RSPM (R 4.2.0) #> sessioninfo 1.2.2 2021-12-06 [3] RSPM (R 4.2.0) #> styler 1.10.2 2023-08-29 [3] RSPM (R 4.2.0) #> utf8 1.2.4 2023-10-22 [3] RSPM (R 4.3.0) #> vctrs 0.6.5 2023-12-01 [3] RSPM (R 4.3.0) #> withr 3.0.0 2024-01-16 [3] RSPM (R 4.3.2) #> xfun 0.42 2024-02-08 [3] RSPM (R 4.3.0) #> yaml 2.3.8 2023-12-11 [3] RSPM (R 4.3.0) #> #> [1] /home/floris/lib/R/library #> [2] /usr/local/lib/R/site-library #> [3] /usr/lib/R/site-library #> [4] /usr/lib/R/library #> #> ────────────────────────────────────────────────────────────────────────────── ```

So the translation is needed to the underlying Ubuntu version, for pak to proceed. I'm not sure what would be the most general approach to solve this for Ubuntu derivatives, but at least this is what Linux Mint provides:

> readLines("/etc/upstream-release/lsb-release")
[1] "DISTRIB_ID=Ubuntu"                             
[2] "DISTRIB_RELEASE=22.04"                         
[3] "DISTRIB_CODENAME=jammy"                        
[4] "DISTRIB_DESCRIPTION=\"Ubuntu Jammy Jellyfish\""
gaborcsardi commented 7 months ago

You can set the sysreqs_platform option or the PKG_SYSREQS_PLATFORM env var to force a platform. See https://pak.r-lib.org/reference/pak-config.html and https://pak.r-lib.org/reference/sysreqs.html

florisvdh commented 7 months ago

Great, thanks!

FWIW if you'd like to add support for Mint, here's a boilerplate function that shows the relation:

mint2ubuntu <- function(mint_version) {
  mint <- substr(mint_version, 1, 2)
  mint <- as.integer(mint_version) - 20L
  data.frame(
    mint_version = mint_version,
    ubuntu_version = paste0(20 + mint * 2, ".04")
  )
}

mintv <- paste0(rep(19:23, each = 4), c("", ".1", ".2", ".3"))
mint2ubuntu(mintv)
#>    mint_version ubuntu_version
#> 1            19          18.04
#> 2          19.1          18.04
#> 3          19.2          18.04
#> 4          19.3          18.04
#> 5            20          20.04
#> 6          20.1          20.04
#> 7          20.2          20.04
#> 8          20.3          20.04
#> 9            21          22.04
#> 10         21.1          22.04
#> 11         21.2          22.04
#> 12         21.3          22.04
#> 13           22          24.04
#> 14         22.1          24.04
#> 15         22.2          24.04
#> 16         22.3          24.04
#> 17           23          26.04
#> 18         23.1          26.04
#> 19         23.2          26.04
#> 20         23.3          26.04

Created on 2024-02-14 with reprex v2.1.0

florisvdh commented 7 months ago

So my current approach to generalize the versions of Mint for pak is to put the following in Rprofile.site (improvements welcome):

ubuntu <- readLines("/etc/upstream-release/lsb-release")
options(pkg.sysreqs_platform = paste0("ubuntu-", regmatches(ubuntu, regexpr("(?<=DISTRIB_RELEASE=).*", ubuntu, perl = TRUE))))