This uses CRAN, CRAN archives, or MRAN (accessed via versions::install.versions) for remote repositories. This will attempt to install all packages in the packageVersionFile, with their exact version described in that file. For GitHub packages, it will use install_github. This will be called internally by Require, and so often doesn't need to be used by a user.

installVersions(gitHubPackages, packageVersionFile = ".packageVersions.txt",
  libPath = .libPaths()[1], standAlone = FALSE,
  repos = getOption("repos"))



Character vectors indicating repository/packageName@branch


Path to the package version file, defaults to the .packageVersions.txt.


The library path where all packages should be installed, and looked for to load (i.e., call library)


Logical. If TRUE, all packages will be installed and loaded strictly from the libPaths only. If FALSE, all .libPaths will be used to find the correct versions. This can be create dramatically faster installs if the user has a substantial number of the packages already in their personal library. In the case of TRUE, there will be a hidden file place in the libPath directory that lists all the packages that were needed during the Require call. Default FALSE to minimize package installing.


The remote repository (e.g., a CRAN mirror), passed to either install.packages, install_github or installVersions.


Because of potential conflicts with loaded packages, this function will run install.packages in a separate R process.


# requires the packageVersionFile -- this doesn't work -- safer to use Require

# make a package version snapshot -- this will be empty because no packages in directory
tempPkgFolder <- file.path(tempdir(), "Packages")
packageVersionFile <- file.path(tempPkgFolder, ".packageVersion.txt")
pkgSnapshot(libPath=tempPkgFolder, packageVersionFile)

Require("crayon", libPath = tempPkgFolder) # install.packages first, then library

# install a specific version
# make a package version snapshot
packageVersionFile <- file.path(tempPkgFolder, ".packageVersion.txt")
pkgSnapshot(libPath=tempPkgFolder, packageVersionFile, standAlone = FALSE)

installVersions("crayon", packageVersionFile = packageVersionFile)

# }