Skip to contents

renv and Pixi solve the same problem: giving each project its own, recorded set of packages. If you know renv, most of rpix will feel familiar.

What’s different

  • Pixi manages R itself, and the system libraries packages need, such as GDAL. With renv, you install those yourself.
  • Packages come from conda-forge, as binaries for every platform, rather than from CRAN. The most used CRAN packages are there; for most of the others, and for packages from GitHub, Pixi can build them from source (experimental). See Finding packages, and How many packages you can use.
  • Each environment has its own R. You start R through Pixi rather than activating a library in the R you already have. See How rpix works.
  • The lock file is always up to date. There’s no snapshot step: adding or removing a package updates pixi.lock.

renv’s functions in rpix

renv rpix or Pixi
renv::init() rpix::use_pixi()
renv::install("dplyr") rpix::pixi_add("dplyr")
renv::remove("dplyr") rpix::pixi_remove("dplyr")
renv::snapshot() Not needed
renv::restore() rpix::pixi_install()
renv::status() rpix::pixi_sitrep(), which says when pixi.lock is out of date, or rpix::pixi_install(locked = TRUE), which fails then
renv::update() rpix::pixi_update(), within the versions pixi.toml allows, or rpix::pixi_upgrade() to raise those
renv.lock pixi.toml and pixi.lock

Moving a project from renv

renv keeps rpix out of the project’s own R, so set the project up from another R session, e.g. your usual R outside the project. use_pixi() notices renv.lock, and offers to move the packages over first:

rpix::use_pixi(path = "~/myproject")
#> ℹ This project uses renv ('renv.lock').
#> ? Would you like to move its packages to Pixi, and turn renv off?
#> 1: Yes
#> 2: No

Yes runs pixi_import_renv(), which:

  • adds the packages in renv.lock to pixi.toml, at least at their locked versions, with the lock file’s version of R. Use versions = "exact" for the locked versions themselves, where conda-forge has them.
  • adds only the packages that nothing else in the lock file needs: the ones your project uses. Pixi installs what they need.
  • adds packages from GitHub too, built from source at the commit renv.lock records, and offers to build CRAN packages that aren’t on conda-forge from source (see When a package isn’t on conda-forge). Building from source is experimental, so it says which packages it built.
  • lists packages it can’t add: those in a subfolder of a GitHub repository, from other sources such as GitLab, and those that aren’t on conda-forge or bioconda and can’t be built.
  • turns renv off, by removing source("renv/activate.R") from .Rprofile. Delete renv.lock and the renv folder when you no longer need them.

Then open the project in your IDE, set up with use_pixi(ide = ) (see Using rpix with an IDE).

For other options, e.g. the locked versions themselves, answer no, and run rpix::pixi_import_renv(versions = "exact", path = "~/myproject") afterwards.