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

avoid false positive for packages installed without known source #1689

Merged
merged 1 commit into from
Sep 13, 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
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