Skip to content

Commit 7a2bbdd

Browse files
committed
chore: add blurb about snapshot behavior
1 parent bd2dfac commit 7a2bbdd

1 file changed

Lines changed: 13 additions & 3 deletions

File tree

docs/docs/10-users/60-sessions/guides/00-environments/20-create-environment-with-custom-packages-installed.md

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -157,16 +157,26 @@ To use `renv` with a code-based environment:
157157
2. Install the packages your project needs as usual, for example:
158158

159159
```r
160-
install.packages(c("dplyr", "ggplot2", "shiny"))
160+
install.packages(c("dplyr", "ggplot2"))
161161
```
162162

163-
3. Snapshot the environment to update the lockfile:
163+
3. Write your analysis code that uses those packages.
164+
165+
4. Snapshot the environment to update the lockfile:
164166

165167
```r
166168
renv::snapshot()
167169
```
168170

169-
4. Commit `renv.lock` at the root (top level) of the code repository. You should also commit the
171+
:::warning
172+
173+
The `renv::snapshot()` command will pick up only the packages that are
174+
installed _and_ used in your source code. If you install packages but do not use them (yet)
175+
they will not be added by default.
176+
177+
:::
178+
179+
5. Commit `renv.lock` at the root (top level) of the code repository. You should also commit the
170180
files created by `renv` that are meant to be shared with the project, such as `.Rprofile` and
171181
`renv/activate.R`.
172182

0 commit comments

Comments
 (0)