GNU/Linux fundamentals for R users

This vignette is for R users who are new to GNU/Linux. It explains the concepts that make sysreqr’s recommendations easier to act on. If you already use apt or dnf daily, you can skip to other vignettes.

What is a Linux distribution?

A Linux distribution (or distro) bundles the Linux kernel with a set of user-space tools, a package manager, default configurations, and a release schedule. The distribution is what you actually install on a server or workstation.

R cares about distributions because:

The distributions sysreqr understands well:

Package managers

A package manager installs, updates, and removes system software from a trusted repository.

Distribution Package manager Lower-level tool
Debian / Ubuntu apt dpkg
Fedora / RHEL 8+ / Rocky dnf rpm
CentOS 7 / older RHEL yum rpm
openSUSE / SLE zypper rpm
Alpine apk (none)
macOS (Homebrew) brew (none)

sysreqr outputs commands that match the platform’s package manager.

Equivalents for common operations

Operation apt dnf / yum zypper apk
Refresh package lists sudo apt-get update (automatic) sudo zypper refresh sudo apk update
Install package(s) sudo apt-get install -y X sudo dnf install -y X sudo zypper --non-interactive install X sudo apk add X
Search apt-cache search X dnf search X zypper search X apk search X
Show info apt-cache show X dnf info X zypper info X apk info X
List installed dpkg -l rpm -qa rpm -qa apk list -I
Remove sudo apt-get remove X sudo dnf remove X sudo zypper remove X sudo apk del X

sudo and root

Most distributions ship with a root (administrator) account that owns system files. Regular users cannot install system packages directly. The sudo command runs one command as root, after asking for the user’s password.

sudo apt-get install -y libxml2-dev

You will see sudo in every install command sysreqr generates that touches system state. Two important consequences:

  1. If you are on a shared server without sudo, you cannot install system packages yourself. Use admin_request() to draft a message to your administrator instead.
  2. sudo does not make R CMD install itself need root. Library paths inside the user’s home directory should not be installed as root.

The -dev and -devel story

R packages that compile from source need development headers, the .h files that describe a library’s interface. On Debian and Ubuntu, the header package has the -dev suffix; on Fedora-style systems, -devel.

For libxml2:

Need Debian/Ubuntu (apt) Fedora/RHEL (dnf)
Run programs linked to libxml2 libxml2 libxml2
Compile against libxml2 libxml2-dev libxml2-devel

sysreqr will pick the right name for the platform. Sometimes a CRAN package needs both a runtime library and a separate tool (like pkg-config); the plan reports each one.

pkg-config

When an R package is built from source, the build script asks pkg-config where to find the system library. pkg-config reads small .pc files that each -dev / -devel package installs.

A typical sign of a missing -dev package is an R build error like:

Package libxml-2.0 was not found in the pkg-config search path.
Perhaps you should add the directory containing `libxml-2.0.pc'
to the PKG_CONFIG_PATH environment variable.

sysreqr::diagnose_log() will translate this back to the missing system package.

Binaries vs. source

CRAN serves source tarballs. When R installs xml2 from source, it may:

Compiling from source is where most “missing system library” failures come from. Two strategies to avoid them:

  1. Use binary R packages: on Linux, point R at the Posit Package Manager binary repository for your distribution. sysreqr::use_ppm() produces the .Rprofile lines for that.
  2. Install the right -dev packages first: sysreqr::setup_advice() and sysreqr::check_packages() will list them.

How sysreqr fits in

sysreqr does not run sudo, does not edit operating system files, and does not install anything. It:

You stay in control.

Common gotchas

Glossary

See also