Skip to content

Commit

Permalink
avoid false positive for packages installed without known source (#1689)
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinushey authored Sep 13, 2023
1 parent 595a1f4 commit 816ed3e
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 3 deletions.
3 changes: 3 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# renv (development version)

* Fixed an issue where `renv` could warn the project appeared to be out-of-sync
when using packages installed without an explicit source recorded. (#1683)

* `renv::install()` gains the `exclude` argument, which can be useful when
installing a subset of project dependencies.

Expand Down
3 changes: 1 addition & 2 deletions R/autoload.R
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@ renv_autoload_impl <- function() {
return(FALSE)

# bail if load is already being called
loading <- getOption("renv.load.running")
if (identical(loading, TRUE))
if (the$load_running)
return(FALSE)

# avoid recursion
Expand Down
5 changes: 4 additions & 1 deletion R/load.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@

# are we currently running 'load()'?
the$load_running <- FALSE

#' Load a project
#'
#' @description
Expand Down Expand Up @@ -69,7 +72,7 @@ load <- function(project = NULL, quiet = FALSE) {
renv_project_lock(project = project)

# indicate that we're now loading the project
renv_scope_options(renv.load.running = TRUE)
renv_scope_binding(the, "load_running", TRUE)

# if load is being called via the autoloader,
# then ensure RENV_PROJECT is unset
Expand Down
14 changes: 14 additions & 0 deletions R/lockfile-diff.R
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,20 @@ renv_lockfile_diff_record <- function(before, after) {
if (!is.null(type))
return(type)

# if we're running this as part of 'load()', and we're comparing
# packages with unknown sources, then just ignore those -- this
# is because we disable the 'guess repository' hack on startup,
# to avoid a potentially expensive query of package repositories
#
# https://github.com/rstudio/renv/issues/1683
if (the$load_running) {
unknown <-
identical(before$Source, "unknown") ||
identical(after$Source, "unknown")
if (unknown)
return(NULL)
}

# check for a crossgrade -- where the package version is the same,
# but details about the package's remotes have changed
if (!setequal(renv_record_names(before), renv_record_names(after)))
Expand Down

0 comments on commit 816ed3e

Please sign in to comment.