pkgSnapshot {Require} | R Documentation |
Take a snapshot of all the packages and version numbers
Description
This can be used later by Require
to install or re-install the correct versions. See examples.
Usage
pkgSnapshot(
packageVersionFile = getOption("Require.packageVersionFile"),
libPaths = .libPaths(),
standAlone = FALSE,
purge = getOption("Require.purge", FALSE),
exact = TRUE,
includeBase = FALSE,
verbose = getOption("Require.verbose")
)
pkgSnapshot2(
packageVersionFile = getOption("Require.packageVersionFile"),
libPaths,
standAlone = FALSE,
purge = getOption("Require.purge", FALSE),
exact = TRUE,
includeBase = FALSE,
verbose = getOption("Require.verbose")
)
Arguments
packageVersionFile |
A filename to save the packages and their currently
installed version numbers. Defaults to |
libPaths |
The path to the local library where packages are installed.
Defaults to the |
standAlone |
Logical. If |
purge |
Logical. Should all caches be purged? Default is
Internally, there are calls to |
exact |
Logical. If |
includeBase |
Logical. Should R base packages be included, specifically,
those in |
verbose |
Numeric or logical indicating how verbose should the function
be. If -1 or -2, then as little verbosity as possible. If 0 or FALSE,
then minimal outputs; if |
Details
A file is written with the package names and versions of all packages within libPaths
.
This can later be passed to Require
.
pkgSnapshot2
returns a vector of package names and versions, with no file output. See
examples.
Value
Will both write a file, and (invisibly) return a vector of packages with the
version numbers. This vector can be used directly in Require
, though it should likely
be used with require = FALSE
to prevent attaching all the packages.
Examples
## Not run:
if (Require:::.runLongExamples()) {
opts <- Require:::.setupExample()
# install one archived version so that below does something interesting
libForThisEx <- tempdir2("Example")
Require("crayon (==1.5.1)", libPaths = libForThisEx, require = FALSE)
# Normal use -- using the libForThisEx for example;
# normally libPaths would be omitted to get all
# packages in user or project library
tf <- tempfile()
# writes to getOption("Require.packageVersionFile")
# within project; also returns a vector
# of packages with version
pkgs <- pkgSnapshot(
packageVersionFile = tf,
libPaths = libForThisEx, standAlone = TRUE # only this library
)
# Now move this file to another computer e.g. by committing in git,
# emailing, googledrive
# on next computer/project
Require(packageVersionFile = tf, libPaths = libForThisEx)
# Using pkgSnapshot2 to get the vector of packages and versions
pkgs <- pkgSnapshot2(
libPaths = libForThisEx, standAlone = TRUE
)
Install(pkgs) # will install packages from previous line
Require:::.cleanup(opts)
unlink(getOption("Require.packageVersionFile"))
}
## End(Not run)