Debian Codegraph @

man/restore.Rd

raw
1 % Generated by roxygen2: do not edit by hand
2 % Please edit documentation in R/restore.R
3 \name{restore}
4 \alias{restore}
5 \title{Restore project library from a lockfile}
6 \usage{
7 restore(
8 project = NULL,
9 ...,
10 library = NULL,
11 lockfile = NULL,
12 packages = NULL,
13 exclude = NULL,
14 rebuild = FALSE,
15 repos = NULL,
16 clean = FALSE,
17 strict = FALSE,
18 transactional = NULL,
19 prompt = interactive()
20 )
21 }
22 \arguments{
23 \item{project}{The project directory. If \code{NULL}, then the active project will
24 be used. If no project is currently active, then the current working
25 directory is used instead.}
26
27 \item{...}{Unused arguments, reserved for future expansion. If any arguments
28 are matched to \code{...}, renv will signal an error.}
29
30 \item{library}{The library paths to be used during restore.}
31
32 \item{lockfile}{Path to a lockfile. When \code{NULL} (the default), the
33 \code{renv.lock} located in the root of the current project will be used.}
34
35 \item{packages}{A subset of packages recorded in the lockfile to restore.
36 When \code{NULL} (the default), all packages available in the lockfile will be
37 restored. Any required recursive dependencies of the requested packages
38 will be restored as well.}
39
40 \item{exclude}{A subset of packages to be excluded during restore. This can
41 be useful for when you'd like to restore all but a subset of packages from
42 a lockfile. Note that if you attempt to exclude a package which is required
43 as the recursive dependency of another package, your request will be
44 ignored.}
45
46 \item{rebuild}{Force packages to be rebuilt, thereby bypassing any installed
47 versions of the package available in the cache? This can either be a
48 boolean (indicating that all installed packages should be rebuilt), or a
49 vector of package names indicating which packages should be rebuilt.}
50
51 \item{repos}{The repositories to use when restoring packages installed
52 from CRAN or a CRAN-like repository. By default, the repositories recorded
53 in the lockfile will be used, ensuring that (e.g.) CRAN packages are
54 re-installed from the same CRAN mirror.
55
56 Use \code{repos = getOption("repos")} to override with the repositories set
57 in the current session, or see the \code{repos.override} option in \link{config} for
58 an alternate way override.}
59
60 \item{clean}{Boolean; remove packages not recorded in the lockfile from
61 the target library? Use \code{clean = TRUE} if you'd like the library state
62 to exactly reflect the lockfile contents after \code{restore()}.}
63
64 \item{strict}{Boolean; when \code{TRUE}, packages whose lockfile records contain
65 a repository URL in the \code{Repository} field will only be retrieved from
66 that exact repository. If the recorded repository is unavailable, the
67 restore will fail rather than falling back to other configured
68 repositories. This can be useful when you need to ensure that packages
69 are installed from a specific source (e.g. an internal package repository).}
70
71 \item{transactional}{Whether or not to use a 'transactional' restore.
72 See \strong{Transactional Restore} for more details. When \code{NULL} (the default),
73 the value of the \code{install.transactional} \code{\link{config}} option will be used.}
74
75 \item{prompt}{Boolean; prompt the user before taking any action? For backwards
76 compatibility, \code{confirm} is accepted as an alias for \code{prompt}.}
77 }
78 \value{
79 A named list of package records which were installed by renv.
80 }
81 \description{
82 Restore a project's dependencies from a lockfile, as previously generated by
83 \code{\link[=snapshot]{snapshot()}}.
84 }
85 \details{
86 \code{renv::restore()} compares packages recorded in the lockfile to
87 the packages installed in the project library. Where there are differences
88 it resolves them by installing the lockfile-recorded package into the
89 project library. If \code{clean = TRUE}, \code{restore()} will additionally delete any
90 packages in the project library that don't appear in the lockfile.
91 }
92 \section{Transactional Restore}{
93
94
95 By default, \code{renv::restore()} will perform a 'transactional' restore, wherein the
96 project library is mutated only if all packages within the lockfile are successfully
97 restored. The intention here is to prevent the private library from entering
98 an inconsistent state, if some subset of packages were to install successfully
99 but some other subset of packages did not. \code{renv::restore(transactional = FALSE)}
100 can be useful if you're attempting to restore packages from a lockfile, but would
101 like to update or change certain packages piece-meal if they fail to install.
102
103 The term 'transactional' here borrows from the parlance of a 'database transaction',
104 where the failure of any intermediate step implies that the whole transaction
105 will be rolled back, so that the state of the database before the transaction
106 was initiated can be preserved. See \url{https://en.wikipedia.org/wiki/Database_transaction}
107 for more details.
108 }
109
110 \examples{
111
112 \dontrun{
113
114 # disable automatic snapshots
115 auto.snapshot <- getOption("renv.config.auto.snapshot")
116 options(renv.config.auto.snapshot = FALSE)
117
118 # initialize a new project (with an empty R library)
119 renv::init(bare = TRUE)
120
121 # install digest 0.6.19
122 renv::install("[email protected]")
123
124 # save library state to lockfile
125 renv::snapshot()
126
127 # remove digest from library
128 renv::remove("digest")
129
130 # check library status
131 renv::status()
132
133 # restore lockfile, thereby reinstalling digest 0.6.19
134 renv::restore()
135
136 # restore automatic snapshots
137 options(renv.config.auto.snapshot = auto.snapshot)
138
139 }
140 }
141 \seealso{
142 Other reproducibility:
143 \code{\link{lockfiles}},
144 \code{\link{snapshot}()}
145 }
146 \concept{reproducibility}