Actually identifying R package System Requirements

During my approximately three years at RStudio there were two things that stumped system admins more than anything: proxied authentication and system dependencies for R package (god help anyone trying to install rgdal on RHEL 7). When RStudio Package Manager (RSPM) v1.0.8 was released there was finally an answer. RSPM can help you identify system requirements via the GUI. Also, there’s a restful API that isn’t fully supported but can provide these system requirements programatically if needed. As such, I think it is still a little used feature for most RSPM users and admins.

{pak} did a great job of providing an interface to the public installation of RSPM. Back in May 2021 I suggested that the API calls to RSPM be made publicly available. Since then pak::pkg_system_requirements() has become an exported function. It is exceptionally useful. I use it in my current work to create a bash script which installs system requirements into a fresh Databricks compute cluster and then install R packages from RSPM.

One of my qualms about the RSPM API and thus the output of pak is that it always includes the installation commands for the provided OS–e.g. apt-get install -y which I suppose could be easily stringr::str_remove()d.

The second qualm has been that this relies on RSPM. The logic has been semi-hidden behind a closed-source tool. However, RStudio maintains a repository r-system-requirements which is used by RSPM to identify system requirements from a packages DESCRIPTION file.

All of the logic for RSPM is in that repository. And that’s why I made https://r-sysreqs.josiahparry.com. It’s a way to provide the REST API functionality from RSPM without having to rely strictly on the public installation.

Users can use the functionality from {sysreqs} to make this api available on their own machines.

sysreqs::get_pkgs_sysreqs(c("rgdal", "igraph"),
                          "ubuntu", "18.04") |> 
  tidyr::unnest(dependencies)
## # A tibble: 6 × 5
##   pkg    name    dependencies pre_installs post_installs
##   <chr>  <chr>   <chr>        <chr>        <chr>        
## 1 rgdal  gdal    libgdal-dev  <NA>         <NA>         
## 2 rgdal  gdal    gdal-bin     <NA>         <NA>         
## 3 rgdal  proj    libproj-dev  <NA>         <NA>         
## 4 igraph glpk    libglpk-dev  <NA>         <NA>         
## 5 igraph gmp     libgmp3-dev  <NA>         <NA>         
## 6 igraph libxml2 libxml2-dev  <NA>         <NA>