Skip to content

Commit

Permalink
renv dependency limit mirrors the rsconnect bundle limit (#969)
Browse files Browse the repository at this point in the history
* renv dependency limit mirrors the rsconnect bundle limit

additionally, do not let renv infer the root.

fixes #968

* news

* skip large directory test on CRAN and CI

Windows is producing (unexpected) snapshot differences that
appear related to file enumeration.

* no progress output; re-enable tests
  • Loading branch information
aronatkins authored Aug 22, 2023
1 parent 6aef657 commit 0d052a0
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 1 deletion.
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# rsconnect (development version)

* Fixed analysis of directories that were smaller than the
`rsconnect.max.bundle.files=10000` limit but larger than the
`renv.config.dependencies.limit=1000` limit. (#968)

# rsconnect 1.0.2

* Fixed redeployments to shinyapps.io where `appName` is provided, but no local
Expand Down
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, progress = FALSE)
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 0d052a0

Please sign in to comment.