- Notifications
You must be signed in to change notification settings - Fork31
System requirements for R packages
License
rstudio/r-system-requirements
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
R packages can depend on one another, but they can also depend on softwareexternal to the R ecosystem. On Ubuntu 24.04, for example, in order to installthecurl R package, you must have previously runapt install libcurl4-openssl-dev. Rpackages often note these dependencies in theSystemRequirements field within theirDESCRIPTION files, but thisinformation is free-form text that varies by package.
This repository contains a catalog of "rules" that can be used to systematicallyidentify these dependencies and generate commands to install them.
You may be expecting to see a list like:
| Package | SystemRequirements | Dependency |
|---|---|---|
curl | libcurl: libcurl-devel (rpm) or libcurl4-openssl-dev (deb). | libcurl4-openssl-dev |
Storing this information as a table in this format is not efficient. Many Rpackages do not have any system dependencies, so the table would be verysparse. Moreover, R packages are added at an exponential rate, so maintainingthis data would be nearly impossible.
Instead, this repository contains a set of rules that map aSystemRequirements field to a platform specific install command such asapt install libcurl4-openssl-dev.
The primary purpose of this catalog is to supportPosit Package Manager,which translates these rules into install commands for specific packages orrepositiories.
You can find the install commands for a package by viewing the package page inPosit Public Package Manager, or using thepakpackage in R.pak will also automatically install the system requirements when installing a package.
While Posit Package Manager is a professional product, this catalog is available as a community resourceunder the MIT license. Please open an issue in this repository for any bugs or requests,or see theFor Developers section for how to contribute to this repository.
The rules in this catalog support the following operating systems:
- Ubuntu 20.04, 22.04, 24.04
- CentOS 7
- Rocky Linux 81, 9
- Red Hat Enterprise Linux 7, 8, 9
- openSUSE 15.6
- SUSE Linux Enterprise 15 SP6
- Debian 12, unstable
- Fedora 41
- Windows (for R 4.0-4.1 only)
We welcome contributions to this catalog! To report a bug or request a rule,please open an issue in this repository. To add or update a rule, fork thisrepository and submit a pull request.
Each system requirement rule is described by a JSON file in therules/directory. The file is namedrule-name.json, whererule-name is typically the name of the system dependency.
For example, here's an excerpt from a rule for the Protocol Buffers (protobuf)library atrules/libprotobuf.json.
{"patterns":["\\blibprotobuf\\b"],// regex which matches "libprotobuf" or "LIBPROTOBUF; libxml2""dependencies":[{"packages":["protobuf-devel"],// to install the package: "yum install protobuf-devel""pre_install":[{"command":"yum install -y epel-release"// add the EPEL repository before installing}],"constraints":[{"os":"linux","distribution":"centos",// make these instructions specific to CentOS 7"versions":["7"]}]}]}
Other examples:
- Simple rule:
git.json - OS version constraints (package names vary by OS version):
libmysqlclient.json - Pre-install steps (adding the EPEL repo on CentOS/RHEL):
gdal.json - Post-install steps (reconfiguring R for Java):
java.json
{"patterns":[...],"dependencies":[{"packages":[...],"constraints":[{"os": ...,"distribution": ...,"versions":[...]}],"pre_install":[{"command": ...,"script": ...}],"post_install":[{"command": ...,"script": ...}]}]}
| Field | Type | Description |
|---|---|---|
patterns | Array | Regular expressions to matchSystemRequirements fields. Case-insensitive. Note that the escape character must be escaped itself (\\. to match a dot). Use word boundaries (\\b) for more accurate matches.Example: ["\\bgnu make\\b", "\\bgmake\\b"] to matchGNU Make orgmake; OpenSSL |
dependencies | Array | Rules for installing the dependency on one or more operating systems. Seedependencies. |
| Field | Type | Description |
|---|---|---|
packages | Array | Packages installed through the default system package manager (e.g. apt, yum, zypper). Examples:["libxml2-dev"],["tcl", "tk"] |
constraints | Array | One or more operating system constraints. Seeconstraints. |
pre_install | Array | Optional commands or scripts to run before installing packages (e.g. adding a third-party repository). Seepre/post-install actions. |
post_install | Array | Optional commands or scripts to run after installing packages (e.g. cleaning up). Seepre/post-install actions. |
| Field | Type | Description |
|---|---|---|
os | String | Operating system. Only"linux" is supported for now. |
distribution | String | Linux distribution. One of"ubuntu","debian","centos","redhat","opensuse","sle","fedora" |
versions | Array | Optional set of OS versions. If unspecified, the rule applies to all supported versions. Seesystems.json for supported values by OS. Example:["24.04"] for Ubuntu. |
Pre-install and post-install actions can be specified as either acommand orscript. Commands are preferred unless there's complicated logic involved.
| Field | Type | Description |
|---|---|---|
command | String | A shell command. Example:"dnf install -y epel-release" |
script | String | A shell script found in thescripts directory. Example:"centos_epel.sh" |
A typical workflow for adding a new rule consists of:
Come up with regular expressions to match all R packages with the systemdependency. See
sysreqs.jsonfor a sample list ofCRAN packages and theirSystemRequirementsfields.Note that the applicable R packages don't have to be on CRAN; they can be onGitHub or other repositories, such as Bioconductor and rOpenSci.Determine the system packages and any pre/post-install steps if needed.The more operating systems covered, the better, but it's fine if only someoperating systems are covered.
Useful resources for finding packages across different OSs:
Or to search for packages on each OS:
# Ubuntu/Debianapt-cache search<package-name># CentOS/RHEL/Fedorayum search<package-name># openSUSE/SLEzypper search<package-name>
Add the new rule as a
rule-name.jsonfile in therulesdirectory.Run the schema tests and (optionally) the system package tests locally.
Submit a pull request.
To lint and validate rules against the schema, you'll needNode.js.
# Install dependenciesnpm install# Run the testsnpmtest
To list R packages and system requirements matched by a rule:
# List matching system requirements for a rulenpm run test-patterns -- rules/libcurl.json --verbose# List matching system requirements for all rulesnpm run test-patterns-all -- --verbose# Fail if a rule doesn't match any system requirementsnpm run test-patterns-all -- --strict
To update the list of R packages and system requirements used for testing, run:
make update-sysreqs
Docker images are provided to help validate systempackages on supported OSs.
Available tags:
focal(Ubuntu 20.04)jammy(Ubuntu 22.04)noble(Ubuntu 24.04)bookworm(Debian 12)sid(Debian unstable)centos7(CentOS 7)centos8(Rocky Linux 8)rockylinux9(Rocky Linux 9)opensuse156(openSUSE 15.6)fedora41(Fedora 41)
To build the images:
# Build a specific image (e.g. noble)make build-noble# Build all imagesmake build-all
To test the rules:
# Test a specific rule on an OS (e.g. noble)make test-noble RULES=rules/libcurl.json# Test a specific rule on all OSsmake test-all RULES=rules/libcurl.json# Test all rules on all OSsmake test-all
The JSON schema is defined in the fileschema.json. Do notmodify this file directly, since it is automatically generated. Instead, modifyschema.template.json and then runnpm run generate-schema. Thegenerate-schema target is automatically run when runningnpm test.
If you need to modify the distros and/or versions supported in the schema definitions,modifysystems.json.
An earlier similarproject maintained by R-Hub has beendeprecated in 2024 in favor of this catalog.
Footnotes
Rocky Linux 8 is specified as
centos8for backward compatibility.CentOS 8 reached end of support on December 31, 2021.↩
About
System requirements for R packages
Topics
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Releases
Packages0
Uh oh!
There was an error while loading.Please reload this page.