rpx documentation

Use an existing project

Lock and synchronize an existing R project.

From a project containing a DESCRIPTION file, resolve its dependencies:

Terminal
rpx lock

This creates rpx.lock, recording the selected package versions and sources without installing them.

Package or legacy project

We recommend keeping your project structured as an R package, with reusable functions that can be loaded from its project library.

Existing projects may need initialization changes before they can be installed as packages. During installation, R evaluates top-level package code and saves the resulting objects for later loading. Code that creates temporary caches, opens connections, or registers loggers at the top level can therefore capture installation-time state instead of initializing it in the session where you use the package.

Create session-dependent resources when the package loads, when they are first needed, or through a setup function. Ordinary functions and closures containing R data do not generally need this treatment.

For legacy code that still depends on being sourced in the current session, DESCRIPTION can mark the project as:

text
Config/rpx/type: project

rpx then manages its dependencies without installing the project itself. If you change this setting after locking, run rpx lock again.

Install the environment

Terminal
rpx sync

rpx installs the locked dependencies into the project library and installs the project itself when it is an R package. Synchronization also replaces mismatched versions and removes packages outside the locked set.

Packages built from source may require compilers and system libraries to be installed beforehand.

Work in the project

Start R with the project library available:

Terminal
rpx run R

Or run a script:

Terminal
rpx run Rscript scripts/check.R

Use rpx status to check whether the project configuration, lockfile, and installed dependencies agree.

Share the environment

Commit DESCRIPTION and rpx.lock. Other developers and CI can recreate the environment with rpx sync; the project library and caches should not be committed.