Cache

ir caches package choices, downloads, and R libraries for runs, renders, and package tools.

Set IR_CACHE_DIR to choose where IR keeps its cache. Downloads go in IR_CACHE_DIR/downloads; set RENV_PATHS_SOURCE to put them elsewhere. IR uses renv’s cache for installed packages. Equivalent artifacts share an installed cache entry across IR cache roots. The entry identifies the selected source or binary, its content metadata, the full R version, and the platform. Downloads have separate subdirectories for each IR root and resolved artifact set, including under an explicit RENV_PATHS_SOURCE. Tools installed with ir tool install keep their libraries under IR_TOOL_STORE_DIR, so they survive ir cache clean.

IR serializes installations that share a writable renv cache and copies packages into each library. Newly materialized libraries remain usable if a renv entry is replaced or removed, or another IR cache is cleaned. These library copies use additional disk space; removing an unused IR cache reclaims its copies. The lock lives in each writable renv cache root and coordinates IR processes. External cache writers must not replace an entry while IR is copying it. Read-only cache roots remain readable without new locks or permission changes. Their owners must keep entries stable while IR copies them, even if nested directories are writable.

When the package requirements, snapshot date, binary preference, and R installation match an earlier run, IR can reuse the cached library without asking pak to choose packages again. R settings such as R_ARCH and R_HOME also affect reuse.

For packages from online sources, cached choices expire after 24 hours by default. This also applies to snapshot repositories, GitHub, GitLab, Bitbucket, git, URL requests, and remote dependencies of local packages. Different exclude-newer dates have separate cached choices. Set IR_LATEST_RESOLUTION_MAX_AGE_SECONDS=0 to check these choices again on every run.

IR always checks local-only requests and requests with pak query modifiers again. For requests that mix local and remote packages, use --refresh to pick up local edits immediately.

Python environments have a separate cache. If a cached Python executable no longer exists, IR prepares the environment again.

IR keeps separate cached package choices for the default binary preference and for IR_PREFER_BINARIES=0. Leaving the variable unset is the same as setting it to 1.

After upgrading to this release, IR chooses packages again to apply the new default. Existing download and package caches are not deleted.

IR reuses a library only when its package versions and download files match what the run needs. Source builds and pre-built binaries of the same version are kept separate. A library from an unfinished installation is not reused. When an explicit source request is resolved again, renv can reuse the installed package if the source is unchanged. If a remote artifact has no content checksum, URL validator, or source revision, a fresh resolution installs it into a new library without adding it to renv’s installed-package cache.

Use --refresh to ask IR to choose R and Python packages again for one invocation:

$ ir run --refresh --with github::r-xla/anvl -e '.libPaths()'
$ ir render --refresh report.qmd
$ rx --refresh btw --help

--refresh is available on ir run, ir render, ir preview, ir tool run, rx, and ir tool install. Set the nonempty environment variable IR_REFRESH for the same behavior. A refresh keeps downloads, installed packages, and existing environments available for reuse. If the refresh fails, the previous cached result is kept.

Commands

$ ir cache dir
$ ir cache clean
$ ir cache clean --force

ir cache dir prints the cache root. ir cache clean removes IR’s cache directory, including saved package choices, downloads, resolver tooling, cached R libraries, and records for Python environments. It does not remove installed tool libraries under IR_TOOL_STORE_DIR. --force is accepted and has the same behavior.

Existing duplicate entries

This change does not delete, migrate, or deduplicate existing renv entries. Older IR libraries may still link to them, as may other renv projects. Existing libraries keep their original references until refreshed. Before removing an entry manually, check its library references and stop processes that use it. Recreate libraries you still need with the current IR version before removing their old entries. Do not deduplicate entries by package name and version alone: different contents, source builds, binaries, R versions, and platforms can require separate installations.