Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Explicit snapshot #1636

Merged
merged 7 commits into from
Aug 16, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: renv
Type: Package
Title: Project Environments
Version: 1.0.0.9000
Version: 1.0.0.9001
Authors@R: c(
person("Kevin", "Ushey", role = c("aut", "cre"), email = "kevin@rstudio.com",
comment = c(ORCID = "0000-0003-2880-7407")),
Expand Down
15 changes: 15 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
# renv 1.0.0.9001 (2023-08-10)

#### ✨ features and improvements

* add `dev` argument to `snapshot` and `status` to be able to capture packages
from *Suggests* with `type="explicit"`; this provides an option to have
a similar behavior of `renv` as before the update to v1.0.0

#### 🐛 bug fixes

#### 💬 documentation etc

#### 🍬 miscellaneous



# renv 1.1.0 (UNRELEASED)

Expand Down
11 changes: 6 additions & 5 deletions R/lockfile.R
Original file line number Diff line number Diff line change
Expand Up @@ -176,30 +176,31 @@ renv_lockfile_create <- function(project,
packages = NULL,
exclude = NULL,
prompt = NULL,
force = NULL)
force = NULL,
dev = FALSE)
{
libpaths <- libpaths %||% renv_libpaths_all()
type <- type %||% settings$snapshot.type(project = project)

# use a restart, so we can allow the user to install packages before snapshot
lockfile <- withRestarts(
renv_lockfile_create_impl(project, type, libpaths, packages, exclude, prompt, force),
renv_lockfile_create_impl(project, type, libpaths, packages, exclude, prompt, force, dev = dev),
renv_recompute_records = function() {
renv_dynamic_reset()
renv_lockfile_create_impl(project, type, libpaths, packages, exclude, prompt, force)
renv_lockfile_create_impl(project, type, libpaths, packages, exclude, prompt, force, dev = dev)
}
)
}

renv_lockfile_create_impl <- function(project, type, libpaths, packages, exclude, prompt, force) {
renv_lockfile_create_impl <- function(project, type, libpaths, packages, exclude, prompt, force, dev = FALSE) {

lockfile <- renv_lockfile_init(project)

# compute the project's top-level package dependencies
packages <- packages %||% renv_snapshot_dependencies(
project = project,
type = type,
dev = FALSE
dev = dev
)

# expand the recursive dependencies of these packages
Expand Down
7 changes: 6 additions & 1 deletion R/snapshot.R
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,9 @@ the$auto_snapshot_hash <- TRUE
#' to the currently active package repositories, as retrieved by
#' `getOption("repos")`.
#'
#' @param dev Boolean; should development dependencies be captured
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it also applies to the type all" Regardless, I'd suggest pointing people to the ?dependencies for more details.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added the link to the dependencies() help into the See Also section for more details about handling R package dependencies. Feel free to modify if you think this should be more prominent in shapshot().

#' (for type `"explicit"`)?
#'
#' @param packages A vector of packages to be included in the lockfile. When
#' `NULL` (the default), all packages relevant for the type of snapshot being
#' performed will be included. When set, the `type` argument is ignored.
Expand Down Expand Up @@ -124,6 +127,7 @@ snapshot <- function(project = NULL,
lockfile = paths$lockfile(project = project),
type = settings$snapshot.type(project = project),
repos = getOption("repos"),
dev = FALSE,
packages = NULL,
exclude = NULL,
prompt = interactive(),
Expand Down Expand Up @@ -171,7 +175,8 @@ snapshot <- function(project = NULL,
packages = packages,
exclude = exclude,
prompt = prompt,
force = force
force = force,
dev = dev
)

if (is.null(lockfile))
Expand Down
9 changes: 6 additions & 3 deletions R/status.R
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ the$status_running <- FALSE
#'
#' # Missing packages
#'
#' `status()` first checks that all packages used by the project are installed.
#' `status()` first checks that all packages used by the project are installed.
#' This must be done first because if any packages are missing we can't tell for
#' sure that a package isn't used; it might be a dependency that we don't know
#' about. Once you have resolve any installation issues, you'll need to run
Expand Down Expand Up @@ -86,6 +86,8 @@ the$status_running <- FALSE
#' cache are installed at the expected + proper locations, and validate the
#' hashes used for those storage locations.
#'
#' @param dev Boolean; should development dependencies be considered?
#'
#' @return This function is normally called for its side effects, but
#' it invisibly returns a list containing the following components:
#'
Expand All @@ -101,7 +103,8 @@ status <- function(project = NULL,
library = NULL,
lockfile = NULL,
sources = TRUE,
cache = FALSE)
cache = FALSE,
dev = FALSE)
{
renv_scope_error_handler()
renv_dots_check(...)
Expand Down Expand Up @@ -129,7 +132,7 @@ status <- function(project = NULL,
lockpath <- lockfile %||% renv_paths_lockfile(project = project)

# get all dependencies, including transitive
dependencies <- renv_snapshot_dependencies(project, dev = FALSE)
dependencies <- renv_snapshot_dependencies(project, dev = dev)
packages <- sort(union(dependencies, "renv"))
paths <- renv_package_dependencies(packages, libpaths = libpaths, project = project)
packages <- as.character(names(paths))
Expand Down