rstudio / rsconnect

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

preserve explicit renv dependency #916

Closed aronatkins closed 1 year ago

aronatkins commented 1 year ago

Given the Shiny application

library(shiny)
library(rsconnect)

ui <- fluidPage("hello")
server <- function(input, output) {}

shinyApp(ui = ui, server = server)

The renv package is not included in the set of required packages due to: https://github.com/rstudio/rsconnect/blob/e7a434a67f6e76d1179b6d666b21d4870ebbc48e/R/bundlePackageRenv.R#L74-L77

packageVersion("rsconnect")
#> [1] '1.0.0'
packageVersion("renv")
#> [1] '1.0.0'
rsconnect::writeManifest()
#> ℹ Capturing R dependencies with renv
#> Warning in is.na(value): is.na() applied to non-(list or vector) of type
#> 'language'
#> Error in if (is.na(value)) default else as.logical(value): the condition has length > 1
manifest <- jsonlite::read_json("manifest.json")
manifest$packages$rsconnect$description$Imports
#> [1] "cli, curl, digest, jsonlite, lifecycle, openssl (>= 2.0.0),\npackrat (>= 0.6), renv (>= 1.0.0), rlang (>= 1.0.0), rstudioapi\n(>= 0.5), tools, yaml (>= 2.1.5)"
manifest$packages$renv
#> NULL

Created on 2023-07-18 with reprex v2.0.2

aronatkins commented 1 year ago

Workaround: Fall back to use packrat for dependency detection (which internally uses renv::dependencies and does not have an renv dependency removed).

options(rsconnect.packrat = TRUE)
aronatkins commented 1 year ago

This issue highlights a difference between renv and packrat: we could disable the implicit packrat dependency.

https://github.com/rstudio/rsconnect/blob/e7a434a67f6e76d1179b6d666b21d4870ebbc48e/R/bundlePackagePackrat.R#L179-L185

aronatkins commented 1 year ago

This issue may be causing folks problems out in the wild, as reported here: https://stackoverflow.com/questions/76711093/missing-dependency-from-rsconnect-when-deploying-shinyapps/76715457#76715457