lockfile-metadata: Get / Set packrat lockfile metadata

lockfile-metadataR Documentation

Get / Set packrat lockfile metadata

Description

Get and set metadata in the current packrat-managed project lockfile packrat.lock

Usage

set_lockfile_metadata(repos = NULL, r_version = NULL, project = NULL)

get_lockfile_metadata(metadata = NULL, simplify = TRUE, project = NULL)

Arguments

repos

A named character vector of the form c(<repoName> = "<pathToRepo>").

r_version

A length-one character vector with suitable numeric version string. See package_version.

project

The project directory. When in packrat mode, defaults to the current project; otherwise, defaults to the current working directory.

metadata

The lockfile field name(s) to draw from.

simplify

Boolean; if TRUE the returned metadata will be un-listed.

Details

Project's packrat.lock contains some metadata before packages dependencies informations. The project's lockfile is created and updated programmatically by snapshot. However it could be necessary sometimes to modify manually some of those values. For example, it could be useful to set another repository CRAN url when deploying to a offline environnement.

available metadata

  • r_version: R version the project depends on

  • repos: Name of repos and their url recorded packages can be retrieve from. Only url is recommended to change if need. Name of repos is used in package records and must be identical

Examples

## Not run: 
# changes repos url
repos <- old_repos <- get_lockfile_metadata("repos")
repos
repos["CRAN"] <- "https://cran.r-project.org/"
set_lockfile_metadata(repos = repos)
get_lockfile_metadata("repos")
# setting back old state
# set_lockfile_metadata(repos = old_repos)

# changes R version
rver <- old_rver <- get_lockfile_metadata("r_version")
rver
rver <- "3.4.1"
set_lockfile_metadata(r_version = rver)
get_lockfile_metadata("r_version")
# Setting back old state
# set_lockfile_metadata(r_version = old_rver)

## End(Not run)

rstudio/packrat documentation built on Feb. 5, 2024, 9:17 p.m.