This can be used later by installVersions to install or re-install the correct versions.

pkgSnapshot(
  packageVersionFile = "packageVersions.txt",
  libPaths,
  standAlone = FALSE,
  purge = getOption("Require.purge", FALSE)
)

Arguments

packageVersionFile

A filename to save the packages and their currently installed version numbers. Defaults to ".packageVersions.txt".

libPaths

The path to the local library where packages are installed. Defaults to the .libPaths()[1].

standAlone

Logical. If TRUE, all packages will be installed to and loaded from the libPaths only. If FALSE, then libPath will be prepended to .libPaths() during the Require call, resulting in shared packages, i.e., it will include the user's default package folder(s). This can be create dramatically faster installs if the user has a substantial number of the packages already in their personal library. Default FALSE to minimize package installing.

purge

Logical. Should all caches be purged Default is getOption("Require.purge", FALSE). There is a lot of internal caching of results throughout the Require package. These help with speed and reduce calls to internet sources. However, sometimes these caches must be purged. The cached values are renewed when found to be too old, with the age limit. This maximum age can be set in seconds with the environment variable R_AVAILABLE_PACKAGES_CACHE_CONTROL_MAX_AGE, or if unset, defaults to 3600 (one hour -- see available.packages).

Internally, there are calls to available.packages

Details

A file is written with the package names and versions of all packages within libPaths. This can later be passed to Require.

Examples

pkgSnapFile <- tempfile() pkgSnapshot(pkgSnapFile, .libPaths()[1])
#> package version file saved in C:\Users\EMCINT~1.L-V\AppData\Local\Temp\Rtmp8g8p7S\file279868a43cc1
data.table::fread(pkgSnapFile)
#> Package #> 1: Require #> LibPath #> 1: C:/Users/emcintir.L-VIC-A023744/AppData/Local/Temp/RtmpeCvjv8/temp_libpath58a822f527fe #> Version GithubRepo GithubUsername GithubRef GithubSHA1 #> 1: 0.0.8 NA NA NA NA
if (FALSE) { # An example to move this file to a new computer library(Require) setLibPaths(.libPaths()[1]) # this will only do a snapshot of the main user library fileName <- "packageSnapshot.txt" pkgSnapshot(fileName) # Get file on another computer -- via email, slack, cloud, etc. # library(googledrive) # (out <- googledrive::drive_upload(fileName)) # copy the file id to clipboard # On new machine fileName <- "packageSnapshot.txt" library(Require) # get the file from email, slack, cloud etc. # library(googledrive) # drive_download(as_id(PASTE-THE-FILE-ID-HERE), path = fileName) setLibPaths("~/RPackages") # start with an empty folder for new # library to minimize package version conflicts Require(packageVersionFile = fileName) }