knitr::opts_chunk$set(
  comment = "#>",
  tidy = FALSE,
  error = FALSE,
  fig.width = 8,
  fig.height = 8)

pkgsnap

Backup and Restore Certain CRAN Package Versions

Project Status: Active - The project has reached a stable, usable state and is being actively developed. Linux Build Status Windows Build status Coverage Status CRAN RStudio mirror downloads

Create a snapshot of your installed CRAN packages with 'snap', and then use 'restore' on another system to recreate exactly the same environment.

Installation

devtools::install_github("mangothecat/pkgsnap")

Usage

library(pkgsnap)

For this experiment we create a new library directory, and install some packages there. We will then remove this directory entirely, and recreate it using pkgsnap.

lib_dir <- tempfile()
dir.create(lib_dir)

We make this new library directory the default:

.libPaths(lib_dir)

The new library directory is currently empty:

installed.packages(lib_dir)[, c("Package", "Version")]

Let's install some packages here. Note that the dependencies of these packages will be also installed.

install.packages(c("testthat", "pkgconfig"))
installed.packages(lib_dir)[, c("Package", "Version")]

We will now create a snapshot, and then scrap the temporary package library.

snapshot <- tempfile()
snap(to = snapshot)
read.csv(snapshot)[1:5,]
unlink(lib_dir, recursive = TRUE)

Create a new package library.

new_lib_dir <- tempfile()
dir.create(new_lib_dir)
.libPaths(new_lib_dir)

Finally, recreate the same set of package versions, in a new package library.

restore(snapshot)
installed.packages(new_lib_dir)[, c("Package", "Version")]

License

MIT © Mango Solutions.



MangoTheCat/pkgsnap documentation built on May 8, 2019, 3:49 p.m.