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", {