ir runs self-describing R scripts and renders Quarto sources.
Put the packages and R version next to the code, then run the file.
ir resolves the requirements, prepares a cached package library, and starts R with that library ready to use.
#!/usr/bin/env -S ir run
#| packages:
#| - dplyr>=1.0
#| - tidyr
#| r-version: ">= 4.0"
#| isolated: true
#| exclude-newer: "2024-01-15"
library(dplyr)
library(tidyr)
1 + 1ir run script.R
./script.RFull documentation: https://r-lib.github.io/ir/
- The file explains itself. R and Python package requirements live in the script or document, not in a separate setup note.
- Fast by design.
irkeeps package setup direct and reuses cached resolutions and libraries when the same requirements are seen again. - Reproducibility is explicit. Use frontmatter
r-version,--r-version, orIR_R_VERSIONto select R by version. Use--rscriptorIR_RSCRIPTonly when you need a machine-local Rscript override. Use--exclude-newer,IR_EXCLUDE_NEWER, or frontmatterexclude-newerto resolve packages as of a specific date. Whenexclude-neweris set without an R selection,irselects the latest R minor version available on that date. - It works with normal R habits. Forward
Rscriptoptions, render Quarto documents, evaluate inline expressions, or use--withfor one-off packages. - Package tools are easy to try. Run package executables with
rx, or install persistent launchers backed by a durable tool store.
ir is designed to be small, fast, and predictable: resolve once, reuse cached libraries aggressively, and avoid making you manage a project directory for a one-file workflow.
ir run script.R
ir run --vanilla script.R
ir render report.qmd --to html
ir run --with cli -e 'cli::cli_alert_success("works")'
ir run --r-version 4.5 script.R
ir run --exclude-newer 2024-01-15 script.R
rx btw --help
ir tool run --from btw btw --help
ir tool install btw
ir cache dirInstall a pre-built binary on Linux or macOS:
curl -fsSL https://raw.githubusercontent.com/r-lib/ir/main/scripts/install.sh | shInstall on Windows PowerShell:
irm https://raw.githubusercontent.com/r-lib/ir/main/scripts/install.ps1 | iexThe installers download the latest release and install ir and rx into ~/.local/bin on Unix or $HOME\bin on Windows.
On macOS, the default ~/.local/bin directory is added to ~/.zprofile when needed.
On Windows, the install directory is added to the user PATH.
On Linux, the installer tells you if the install directory is not on PATH.
If rig is not on PATH, the installers print platform-specific rig install guidance.
Set IR_NO_MODIFY_PATH=1 to skip PATH changes.
Set IR_INSTALL_DIR to choose another directory.
You can also build from source with Rust:
cargo build --releaseThis builds target/release/ir and target/release/rx.
To install the system dependencies needed to build the project and run tests on a new machine, run:
scripts/install-dev-deps.shOn Windows PowerShell, run:
.\scripts\install-dev-deps.ps1The setup scripts install Rust, Python, rig, the current R release, rig's
oldrel/2 R for the version-selection tests, and Quarto. They do not run tests
or pre-warm package caches. Pass --dry-run on Unix or -DryRun on Windows to
inspect the plan.
R/RscriptonPATH, or--rscript/IR_RSCRIPT, when R is not selected by version or date.rigonPATHwhen usingr-version,IR_R_VERSION,--r-version, or date-onlyexclude-newerR selection.quartoonPATH, orIR_QUARTO, when rendering.qmd,.Rmd, or R script files.
On first use, ir prepares its resolver tooling in its cache, so you do not need to pre-install pak or renv.
For command details, configuration, and edge cases, see:
MIT. See LICENSE.