rstudio / rsconnect

Publish Shiny Applications, RMarkdown Documents, Jupyter Notebooks, Plumber APIs, and more
http://rstudio.github.io/rsconnect/
133 stars 81 forks source link

error reporting large directories #968

Closed aronatkins closed 1 year ago

aronatkins commented 1 year ago

Set-up:

# create a new project
usethis::create_project("~/Desktop/many-files")
# within the project, create a shiny application
writeLines(c(
        "shinyApp(ui = fluidPage('so many files.'), server = function(input, output){})"
    ), "app.R")
# create many (tiny) files
dir.create("so-many-files")
for (each in seq_len(1001)) { writeLines(character(0), file.path("so-many-files", paste0(each, ".txt")))}

Error:

rsconnect::writeManifest()
#> ℹ Capturing R dependencies with renv
#> Error in dirname(root): a character vector argument expected

Created on 2023-08-22 with reprex v2.0.2

aronatkins commented 1 year ago

This may be related to https://github.com/rstudio/renv/issues/1657.

Additionally, renv has its own renv.config.dependencies.limit option that is used to control the number of files allowed when scanning for dependencies.

rsconnect should mirror its rsconnect.max.bundle.files value onto renv.config.dependencies.limit before using renv::dependencies().

aronatkins commented 1 year ago

The stack from the rsconnect::writeManifest() error:

21: dirname(root) at dependencies.R#429
20: nchar(prefix)
19: substring(string, 1, nchar(prefix)) at bootstrap.R#36
18: startswith(path, root) at path.R#147
17: renv_path_relative(path, dirname(root)) at dependencies.R#429
16: renv_dependencies_find_dir_children(path, root, depth) at dependencies.R#399
15: renv_dependencies_find_dir(path, root, depth) at dependencies.R#376
14: FUN(X[[i]], ...)
13: lapply(x, f, ...) at utils-map.R#57
12: map(children, renv_dependencies_find_impl, root = root, depth = depth) at dependencies.R#406
11: renv_dependencies_find_dir(path, root, depth) at dependencies.R#376
10: FUN(X[[i]], ...)
9: lapply(path, renv_dependencies_find_impl, root = root, depth = 0) at dependencies.R#353
8: renv_dependencies_find(path, root) at dependencies.R#236
7: renv_dependencies_impl(path = path, root = root, quiet = quiet, 
       progress = progress, errors = errors, dev = dev, ...) at dependencies.R#195
6: renv::dependencies(bundleDir) at bundlePackageRenv.R#14
5: snapshotRenvDependencies(bundleDir, extraPackages, verbose = verbose) at bundlePackage.R#66
4: computePackageDependencies(bundleDir, extraPackages, quiet = quiet, 
       verbose = verbose) at bundlePackage.R#7
3: bundlePackages(bundleDir = appDir, extraPackages = extraPackages, 
       verbose = verbose, quiet = quiet) at bundle.R#118
2: createAppManifest(appDir = bundleDir, appMetadata = appMetadata, 
       pythonConfig = pythonConfig, retainPackratDirectory = FALSE, 
       image = image, verbose = verbose, quiet = quiet) at writeManifest.R#58
1: rsconnect::writeManifest()
aronatkins commented 1 year ago

Caused by https://github.com/rstudio/renv/issues/1658

aronatkins commented 1 year ago

Workaround: Avoid renv large-directory enforcement.

options(rsconnect.max.bundle.files = 100000, renv.config.dependencies.limit = 100000)