Skip to content

Commit

Permalink
renv dependency limit mirrors the rsconnect bundle limit
Browse files Browse the repository at this point in the history
additionally, do not let renv infer the root.

fixes #968
  • Loading branch information
aronatkins committed Aug 22, 2023
1 parent 6aef657 commit dc3d289
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 1 deletion.
11 changes: 10 additions & 1 deletion R/bundlePackageRenv.R
Original file line number Diff line number Diff line change
Expand Up @@ -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))

Expand Down
5 changes: 5 additions & 0 deletions tests/testthat/_snaps/bundlePackageRenv.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# large directories are analyzed

Code
deps <- snapshotRenvDependencies(app_dir)

# errors if library and project are inconsistent

Code
Expand Down
14 changes: 14 additions & 0 deletions tests/testthat/test-bundlePackageRenv.R
Original file line number Diff line number Diff line change
Expand Up @@ -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", {
Expand Down

0 comments on commit dc3d289

Please sign in to comment.