From dc3d289f006844b4792c6db9819f5061e9b8ed50 Mon Sep 17 00:00:00 2001 From: Aron Atkins Date: Tue, 22 Aug 2023 10:12:33 -0400 Subject: [PATCH] renv dependency limit mirrors the rsconnect bundle limit additionally, do not let renv infer the root. fixes #968 --- R/bundlePackageRenv.R | 11 ++++++++++- tests/testthat/_snaps/bundlePackageRenv.md | 5 +++++ tests/testthat/test-bundlePackageRenv.R | 14 ++++++++++++++ 3 files changed, 29 insertions(+), 1 deletion(-) diff --git a/R/bundlePackageRenv.R b/R/bundlePackageRenv.R index 2ae9484d..7769e44d 100644 --- a/R/bundlePackageRenv.R +++ b/R/bundlePackageRenv.R @@ -9,9 +9,18 @@ snapshotRenvDependencies <- function(bundleDir, ) defer(options(old)) + dependenciesLimit <- getOption("renv.config.dependencies.limit") + if (is.null(dependenciesLimit)) { + maxFiles <- getOption("rsconnect.max.bundle.files", 10000) + oldlim <- options( + renv.config.dependencies.limit = maxFiles + ) + defer(options(oldlim)) + } + # analyze code dependencies ourselves rather than relying on the scan during renv::snapshot, as # that will add renv to renv.lock as a dependency. - deps <- renv::dependencies(bundleDir) + deps <- renv::dependencies(bundleDir, root = bundleDir) renv::snapshot(bundleDir, packages = deps$Package, prompt = FALSE) defer(removeRenv(bundleDir)) diff --git a/tests/testthat/_snaps/bundlePackageRenv.md b/tests/testthat/_snaps/bundlePackageRenv.md index 240a8d82..29b9b130 100644 --- a/tests/testthat/_snaps/bundlePackageRenv.md +++ b/tests/testthat/_snaps/bundlePackageRenv.md @@ -1,3 +1,8 @@ +# large directories are analyzed + + Code + deps <- snapshotRenvDependencies(app_dir) + # errors if library and project are inconsistent Code diff --git a/tests/testthat/test-bundlePackageRenv.R b/tests/testthat/test-bundlePackageRenv.R index 7e9d9d28..f2b7f642 100644 --- a/tests/testthat/test-bundlePackageRenv.R +++ b/tests/testthat/test-bundlePackageRenv.R @@ -56,6 +56,20 @@ test_that("works with BioC packages", { expect_equal(Biobase$Repository, biocRepos(".")[[1]]) }) +# https://github.com/rstudio/rsconnect/issues/968 +test_that("large directories are analyzed", { + app_dir <- local_temp_app(list("foo.R" = "library(foreign)")) + data_dir <- file.path(app_dir, "data") + dir.create(data_dir) + for (each in seq_len(1001)) { + writeLines(character(0), file.path(data_dir, paste0(each, ".txt"))) + } + expect_snapshot( + deps <- snapshotRenvDependencies(app_dir) + ) + expect_contains(deps$Package, "foreign") +}) + # parseRenvDependencies --------------------------------------------------- test_that("gets DESCRIPTION from renv & system libraries", {