Last updated: 2026-02-06
R + apt: A Python-free alternative to bspm for r2u binary installs.
What it does
Makes install.packages("dplyr") install r-cran-dplyr via apt instead of compiling from source. Fast binary installs with no Python in the stack.
Architecture
R session → Unix socket → raptd (root) → apt install r-cran-*
A minimal C daemon (raptd) listens on /run/raptd.sock and executes apt commands on behalf of unprivileged users.
Installation and Usage
With .deb (recommended)
Install build dependencies as needed
sudo apt install debhelper r-base-dev
Clone repo and cd:
git clone https://github.com/cornball-ai/rapt.git
cd rapt/pkg
Build .deb and install:
# Build
dpkg-buildpackage -us -uc -b
# Install
sudo apt install ../rapt_0.1.0-1_amd64.deb
The .deb installs everything: daemon, systemd units, R package, and enables rapt system-wide.
After installing the .deb, rapt is enabled automatically. Just use R normally:
install.packages("dplyr")
#> Installing via apt: dplyr
With the R package only (no daemon, no systemd)
Clone repo and install:
git clone https://github.com/cornball-ai/rapt.git
cd rapt/r-pkg/
R CMD INSTALL .
Or without cloning:
remotes::install_github("cornball-ai/rapt", subdir = "r-pkg")
Then in R:
rapt::enable()
install.packages("dplyr") # now goes through apt via sudo
To make it permanent, add to ~/.Rprofile:
if (requireNamespace("rapt", quietly = TRUE)) rapt::enable()
Passwordless sudo for apt
Without the daemon, rapt falls back to sudo apt. To avoid password prompts, add a sudoers rule limited to R packages:
# /etc/sudoers.d/rapt
%users ALL=(root) NOPASSWD: /usr/bin/apt install -y r-cran-*
%users ALL=(root) NOPASSWD: /usr/bin/apt remove -y r-cran-*
%users ALL=(root) NOPASSWD: /usr/bin/apt install -y r-bioc-*
%users ALL=(root) NOPASSWD: /usr/bin/apt remove -y r-bioc-*
Manual control
library(rapt)
# Check status
manager()
#> $daemon_available
#> [1] TRUE
#> $socket_path
#> [1] "/run/raptd.sock"
#> $enabled
#> [1] TRUE
# Direct system package management
install_sys("ggplot2")
remove_sys("ggplot2")
# List available system packages
head(available_sys())
#> [1] "a]4" "abc" "abcrf" "abd" "abess" "abn"
# Disable/enable hook
disable()
install.packages("dplyr") # Now uses CRAN
enable()
install.packages("dplyr") # Back to apt
Configuration
Options (set in ~/.Rprofile or /etc/R/Rprofile.site):
# Allow sudo fallback when daemon unavailable (default: FALSE in non-interactive)
options(rapt.sudo = TRUE)
# Custom socket path (default: /run/raptd.sock)
options(rapt.socket = "/run/raptd.sock")
Requirements
- Ubuntu with r2u configured
- R >= 4.0
- systemd (optional — for the daemon; without it, falls back to sudo/root)
How it compares to bspm
| bspm | rapt | |
|---|---|---|
| Backend | Python D-Bus → PackageKit | C daemon → apt |
| Dependencies | Python, dbus-python, PackageKit | libc |
| Socket | D-Bus system bus | Unix domain socket |
| Lines of code | ~1500 | ~500 |
License
MIT
Reference
See Function Reference for complete API documentation.
Functions
rapt Reference
Function reference for rapt