Skip to main content

ir

ir runs self-describing R scripts and renders or previews 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
#|   - tidyr==1.3.1
#| r-version: ">= 4.3"
#| isolated: true
#| exclude-newer: "2024-02-01"

airquality |> tidyr::drop_na(Ozone) |> dplyr::count(Month)
ir run script.R
./script.R

This records a last-known-good environment: tidyr is pinned to the version tested with the script, while the snapshot date selects dplyr and the transitive dependencies.

Full documentation: https://r-lib.github.io/ir/

Why use it?

  • The file explains itself. R and Python package requirements live in the script or document, not in a separate setup note.
  • Fast by design. ir prefers pre-built R packages and reuses cached resolutions and libraries when the same requirements are seen again.
  • Reproducibility is explicit. Use frontmatter r-version, --r-version, or IR_R_VERSION to select R by version. Use --rscript or IR_RSCRIPT only when you need a machine-local Rscript override. Use --exclude-newer, IR_EXCLUDE_NEWER, or frontmatter exclude-newer to resolve the default CRAN and Bioconductor repositories from Posit Package Manager snapshots as of a specific date. Without another R selector, the date selects the latest R minor released by then. When r-version can match more than one R minor, the date limits selection to minor versions released by then.
  • It works with normal R habits. Forward Rscript options, render or preview Quarto documents, evaluate inline expressions, or use --with for 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.

Common commands

ir run script.R
ir run --vanilla script.R
ir render report.qmd --to html
ir preview report.qmd
ir run --with cli -e 'cli::cli_alert_success("works")'
ir run --with BiocGenerics -e 'library(BiocGenerics)'
ir run --r-version 4.3 script.R
ir run --exclude-newer 2024-02-01 script.R
rx btw --help
ir tool run --from btw btw --help
ir tool install btw
ir cache dir

Bioconductor packages use their bare package names. pak selects the Bioconductor release compatible with the selected R.

Install

Install from PyPI with uv:

uv tool install r-lib-ir

This installs both ir and rx. If the uv tool executable directory is not already on PATH, run uv tool update-shell.

Install a pre-built binary on Linux or macOS:

curl -fsSL https://raw.githubusercontent.com/r-lib/ir/main/scripts/install.sh | sh

Install on Windows with Scoop using the r-bucket bucket:

scoop bucket add r-bucket https://github.com/cderv/r-bucket.git
scoop install ir

Alternatively, install the Windows binary directly from PowerShell:

irm https://raw.githubusercontent.com/r-lib/ir/main/scripts/install.ps1 | iex

The direct 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 --release

This builds target/release/ir and target/release/rx.

Development setup

To install the system dependencies needed to build the project and run tests on a new machine, run:

scripts/install-dev-deps.sh

On Windows PowerShell, run:

.\scripts\install-dev-deps.ps1

The setup scripts install Rust, Python, rig, the current R release, R 4.3 for the version-selection and documentation example 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.

Requirements

  • R / Rscript on PATH, or --rscript/IR_RSCRIPT, when R is not selected by version or date.
  • rig on PATH when using r-version, IR_R_VERSION, --r-version, or date-only exclude-newer R selection.
  • quarto on PATH, or IR_QUARTO, when rendering or previewing .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.

Learn more

For command details, configuration, and edge cases, see:

License

MIT. See LICENSE.

Metadata

Release files for r-lib-ir 0.4.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distributions (wheels)

Table of built distributions (wheels) for r-lib-ir 0.4.1
File
r_lib_ir-0.4.1-py3-none-win_amd64.whl Python 3 none Windows x86-64 Details
r_lib_ir-0.4.1-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl Python 3 none Linux glibc 2.17+ x86-64 Details
r_lib_ir-0.4.1-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl Python 3 none Linux glibc 2.17+ ARM64 Details
r_lib_ir-0.4.1-py3-none-macosx_11_0_arm64.whl Python 3 none macOS 11.0+ ARM64 Details
r_lib_ir-0.4.1-py3-none-macosx_10_12_x86_64.whl Python 3 none macOS 10.12+ x86-64 Details

Total release size: 4.5 MB

Release files / r_lib_ir-0.4.1-py3-none-win_amd64.whl

Download URL r_lib_ir-0.4.1-py3-none-win_amd64.whl
Size 827.2 kB
Tags Python 3 Windows x86-64
SHA-256 checksum
How to use checksums
d3d2326f400372d02bed1d7964600838bb89861392cb58a301d0451a2ce00805
BLAKE2b-256 checksum
How to use checksums
04baef275b14240d36eca45e70b3c01c9d72eab7fc23a63e5452a2683ca3d2dd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.21 {"installer":{"name":"uv","version":"0.12.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"22.04","id":"jammy","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / r_lib_ir-0.4.1-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL r_lib_ir-0.4.1-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 954.3 kB
Tags Linux glibc 2.17+ x86-64 Python 3
SHA-256 checksum
How to use checksums
25c8c7737c5dc8c4e3d87472d079373000593ae29f3317d2ced74926d4b1039a
BLAKE2b-256 checksum
How to use checksums
7a8af4964628fce4cef8fae55f75ada799d14dc3a6da9ee49c3985d387e3e378
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.21 {"installer":{"name":"uv","version":"0.12.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"22.04","id":"jammy","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / r_lib_ir-0.4.1-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl

Download URL r_lib_ir-0.4.1-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Size 896.9 kB
Tags Linux glibc 2.17+ ARM64 Python 3
SHA-256 checksum
How to use checksums
3ed3ba1185056cdf8518a7bbdeaf974e6aae0d079d0cfb860f6a4607ed366053
BLAKE2b-256 checksum
How to use checksums
896c2590a87ec2c4966f1bd6485a474517c1502748b68ad578966cf41ba03734
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.21 {"installer":{"name":"uv","version":"0.12.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"22.04","id":"jammy","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / r_lib_ir-0.4.1-py3-none-macosx_11_0_arm64.whl

Download URL r_lib_ir-0.4.1-py3-none-macosx_11_0_arm64.whl
Size 887.8 kB
Tags Python 3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
b006c4d6e5ae030816c3a05babaab3eb3ac7ae3b8821f6afa8372092d4d2783d
BLAKE2b-256 checksum
How to use checksums
da0bfcf74f60789e260219f54a52c1ef8e15c531de1d8ebed1ec71091be7fd87
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.21 {"installer":{"name":"uv","version":"0.12.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"22.04","id":"jammy","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / r_lib_ir-0.4.1-py3-none-macosx_10_12_x86_64.whl

Download URL r_lib_ir-0.4.1-py3-none-macosx_10_12_x86_64.whl
Size 928.1 kB
Tags Python 3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
393f0f7dc7de1973afe682a43711ec6399a3b3295142bde3e9bc42b76150a4c1
BLAKE2b-256 checksum
How to use checksums
2a608228debc300d55a7f369b0ba3dfff34df12e56a3c2f319517d5e9df63c92
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.21 {"installer":{"name":"uv","version":"0.12.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"22.04","id":"jammy","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release history Release notifications | RSS feed

This release

0.4.1 This release

5 release files

0.4.0

5 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page