Skip to content

rv run

Introduced in rv v0.22.0

Runs an Rscript invocation with the project’s library paths configured, so scripts execute against the packages managed by rv without needing to activate the project first.

By default, rv run syncs the project library before running the script, ensuring it always runs against a library that matches the config and lock files.

Terminal window
rv run [--no-sync] [args]...
  • args - The Rscript arguments to run, e.g. a script path and any arguments it takes. Everything after rv run (and --no-sync, if present) is passed through to Rscript unmodified.
  • --no-sync must be first - Skip syncing the project library before running the command. Because all other arguments are passed through to Rscript as-is, this flag must be given as the very first argument or it will be treated as an argument to your script instead.
  • --r-bin <PATH> - Use the R at that path instead of the one rv finds for the project. See overriding the R version Introduced in rv v0.23.0
  • --r-version <VERSION> - Paired with --r-bin, run against an R that does not match the config. The lockfile is then neither read nor updated Introduced in rv v0.23.0
Terminal window
% rv run analysis.R
+ tibble (3.2.1, binary from https://packagemanager.posit.co/cran/latest) in 0ms
...

To skip the sync and run directly against the current library:

Terminal window
% rv run --no-sync analysis.R

If the script contains a # /// rv block, rv run takes its configuration from there instead of from an rproject.toml, and installs the dependencies it declares in a library kept in the cache:

analysis.R
# /// rv
# dependencies = ["dplyr"]
# ///
library(dplyr)
Terminal window
rv run analysis.R

See self-contained scripts for the details of the block and what rv fills in for you.