Depending on how you prefer to manage dependencies, you might prefer
selecting a different snapshot mode. The modes available are as follows:
"all"
Capture all packages within the active R libraries in the lockfile.
This is the quickest and simplest method, but may lead to undesired
packages (e.g. development dependencies) entering the lockfile.
"implicit"
Only capture packages which appear to be used in your project in the
lockfile. The intersection of packages installed in your R libraries,
alongside those used in your R code as inferred by renv::dependencies()
,
will enter the lockfile. This helps ensure that only the packages your
project requires will enter the lockfile, but may be slower if your project
contains a large number of files. If this becomes an issue, you might
consider using .renvignore
files to limit which files renv
uses for
dependency discovery, or explicitly declaring your required dependencies in a
DESCRIPTION
file. You can also force a dependency on a particular package
by writing e.g. library(<package>)
into a file called dependencies.R
.
"explicit"
Only capture packages which are explicitly listed in the project
DESCRIPTION
file. This workflow is recommended for users who wish to more
explicitly manage a project's R package dependencies.
"custom"
Like "implicit"
, but use a custom user-defined filter instead. The filter
should be specified by the R option renv.snapshot.filter
, and should
either be a character vector naming a function (e.g. "package::method"
),
or be a function itself. The function should only accept one argument (the
project directory), and should return a vector of package names to include
in the lockfile.
By default, "implicit"
-style snapshots are used. The snapshot type can be
configured on a project-specific basis using the renv
project settings
mechanism.
When the packages
argument is set, type
is ignored, and instead only the
requested set of packages, and their recursive dependencies, will be written
to the lockfile.