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 all 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
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# renv (development version)

* 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

# renv 1.0.2

* renv now parses package `NAMESPACE` files for imported dependencies. (#1637)
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
9 changes: 8 additions & 1 deletion R/snapshot.R
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,13 @@ the$auto_snapshot_hash <- TRUE
#'
#' See **Snapshot type** below for more details.
#'
#' @inheritParams dependencies
#'
#' @param repos The \R repositories to be recorded in the lockfile. Defaults
#' to the currently active package repositories, as retrieved by
#' `getOption("repos")`.
#'
#'
#' @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 All @@ -113,6 +116,8 @@ the$auto_snapshot_hash <- TRUE
#' @return The generated lockfile, as an \R object (invisibly). Note that
#' this function is normally called for its side effects.
#'
#'
#' @seealso More on handling package [dependencies()]
#' @family reproducibility
#'
#' @export
Expand All @@ -123,6 +128,7 @@ snapshot <- function(project = NULL,
library = NULL,
lockfile = paths$lockfile(project = project),
type = settings$snapshot.type(project = project),
dev = FALSE,
repos = getOption("repos"),
packages = NULL,
exclude = NULL,
Expand Down Expand Up @@ -171,7 +177,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.
#'
#' @inheritParams dependencies
#'
#' @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
13 changes: 13 additions & 0 deletions man/snapshot.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 12 additions & 1 deletion man/status.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.