Debian Codegraph @

man/status.Rd

raw
1 % Generated by roxygen2: do not edit by hand
2 % Please edit documentation in R/status.R
3 \name{status}
4 \alias{status}
5 \title{Report inconsistencies between lockfile, library, and dependencies}
6 \usage{
7 status(
8 project = NULL,
9 ...,
10 library = NULL,
11 lockfile = NULL,
12 sources = TRUE,
13 cache = FALSE,
14 dev = NULL
15 )
16 }
17 \arguments{
18 \item{project}{The project directory. If \code{NULL}, then the active project will
19 be used. If no project is currently active, then the current working
20 directory is used instead.}
21
22 \item{...}{Unused arguments, reserved for future expansion. If any arguments
23 are matched to \code{...}, renv will signal an error.}
24
25 \item{library}{The library paths. By default, the library paths associated
26 with the requested project are used.}
27
28 \item{lockfile}{Path to a lockfile. When \code{NULL} (the default), the
29 \code{renv.lock} located in the root of the current project will be used.}
30
31 \item{sources}{Boolean; check that each of the recorded packages have a
32 known installation source? If a package has an unknown source, renv
33 may be unable to restore it.}
34
35 \item{cache}{Boolean; perform diagnostics on the global package cache?
36 When \code{TRUE}, renv will validate that the packages installed into the
37 cache are installed at the expected + proper locations, and validate the
38 hashes used for those storage locations.}
39
40 \item{dev}{Boolean; include development dependencies? These packages are
41 typically required when developing the project, but not when running it
42 (i.e. you want them installed when humans are working on the project but
43 not when computers are deploying it).
44
45 Development dependencies include packages listed in the \code{Suggests} field
46 of a \code{DESCRIPTION} found in the project root, and roxygen2 or devtools if
47 their use is implied by other project metadata. They also include packages
48 used in \verb{~/.Rprofile} if \code{config$user.profile()} is \code{TRUE}.}
49 }
50 \value{
51 This function is normally called for its side effects, but
52 it invisibly returns a list containing the following components:
53 \itemize{
54 \item \code{library}: packages in your library.
55 \item \code{lockfile}: packages in the lockfile.
56 \item \code{synchronized}: are the library and lockfile in sync?
57 }
58 }
59 \description{
60 \code{renv::status()} reports issues caused by inconsistencies across the project
61 lockfile, library, and \code{\link[=dependencies]{dependencies()}}. In general, you should strive to
62 ensure that \code{status()} reports no issues, as this maximizes your chances of
63 successfully \code{restore()}ing the project in the future or on another machine.
64
65 \code{renv::load()} will report if any issues are detected when starting an
66 renv project; we recommend resolving these issues before doing any
67 further work on your project.
68
69 See the headings below for specific advice on resolving any issues
70 revealed by \code{status()}.
71 }
72 \section{Missing packages}{
73 \code{status()} first checks that all packages used by the project are installed.
74 This must be done first because if any packages are missing we can't tell for
75 sure that a package isn't used; it might be a dependency that we don't know
76 about. Once you have resolve any installation issues, you'll need to run
77 \code{status()} again to reveal the next set of potential problems.
78
79 There are four possibilities for an uninstalled package:
80 \itemize{
81 \item If it's used and recorded, call \code{renv::restore()} to install the version
82 specified in the lockfile.
83 \item If it's used and not recorded, call \code{renv::install()} to install it
84 from CRAN or elsewhere.
85 \item If it's not used and recorded, call \code{renv::snapshot()} to
86 remove it from the lockfile.
87 \item If it's not used and not recorded, there's nothing to do. This the most
88 common state because you only use a small fraction of all available
89 packages in any one project.
90 }
91
92 If you have multiple packages in an inconsistent state, we recommend
93 \code{renv::restore()}, then \code{renv::install()}, then \code{renv::snapshot()}, but
94 that also suggests you should be running status more frequently.
95 }
96
97 \section{Lockfile vs \code{dependencies()}}{
98 Next we need to ensure that packages are recorded in the lockfile if and
99 only if they are used by the project. Fixing issues of this nature only
100 requires calling \code{snapshot()} because there are four possibilities for
101 a package:
102 \itemize{
103 \item If it's used and recorded, it's ok.
104 \item If it's used and not recorded, call \code{renv::snapshot()} to add it to the
105 lockfile.
106 \item If it's not used but is recorded, call \code{renv::snapshot()} to remove
107 it from the lockfile.
108 \item If it's not used and not recorded, it's also ok, as it may be a
109 development dependency.
110 }
111 }
112
113 \section{Out-of-sync sources}{
114 The final issue to resolve is any inconsistencies between the version of
115 the package recorded in the lockfile and the version installed in your
116 library. To fix these issues you'll need to either call \code{renv::restore()}
117 or \code{renv::snapshot()}:
118 \itemize{
119 \item Call \code{renv::snapshot()} if your project code is working. This implies that
120 the library is correct and you need to update your lockfile.
121 \item Call \code{renv::restore()} if your project code isn't working. This probably
122 implies that you have the wrong package versions installed and you need
123 to restore from known good state in the lockfile.
124 }
125
126 If you're not sure which case applies, it's generally safer to call
127 \code{renv::snapshot()}. If you want to rollback to an earlier known good
128 status, see \code{\link[=history]{history()}} and \code{\link[=revert]{revert()}}.
129 }
130
131 \section{Different R Version}{
132 renv will also notify you if the version of R used when the lockfile was
133 generated, and the version of R currently in use, do not match. In this
134 scenario, you'll need to consider:
135 \itemize{
136 \item Is the version of R recorded in the lockfile correct? If so, you'll want
137 to ensure that version of R is installed and used when working in this
138 project.
139 \item Otherwise, you can call \code{renv::snapshot()} to update the version of R
140 recorded in the lockfile, to match the version of R currently in use.
141 }
142
143 If you'd like to set the version of R recorded in a lockfile independently
144 of the version of R currently in use, you can set the \code{r.version} project
145 setting -- see \link{settings} for more details.
146 }
147
148 \examples{
149
150 \dontrun{
151
152 # disable automatic snapshots
153 auto.snapshot <- getOption("renv.config.auto.snapshot")
154 options(renv.config.auto.snapshot = FALSE)
155
156 # initialize a new project (with an empty R library)
157 renv::init(bare = TRUE)
158
159 # install digest 0.6.19
160 renv::install("[email protected]")
161
162 # save library state to lockfile
163 renv::snapshot()
164
165 # remove digest from library
166 renv::remove("digest")
167
168 # check library status
169 renv::status()
170
171 # restore lockfile, thereby reinstalling digest 0.6.19
172 renv::restore()
173
174 # restore automatic snapshots
175 options(renv.config.auto.snapshot = auto.snapshot)
176
177 }
178 }