Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] App not deploying on Shiny Server #1135

Closed
shumza-nali opened this issue Mar 27, 2024 · 5 comments
Closed

[BUG] App not deploying on Shiny Server #1135

shumza-nali opened this issue Mar 27, 2024 · 5 comments

Comments

@shumza-nali
Copy link

shumza-nali commented Mar 27, 2024

Describe the bug

I am attempting to deploy my app on a company hosted shiny server with renv to isolate the environment.

Apps which are not developed with the golem framework are deploying fine, whereas any App built with the golem framework does not deploy.

The app runs with golem::run_dev().

In my log file it states there is no package called jsonlite but I have installed jsonlite with install.packages() and I can see it in the renv lock file.

To reproduce

  1. New golem project. Install with standard instructions here.

  2. Navigate to 03_deploy.R. No errors with devtools::check(). Package installed with devtools::install() and is able to run with run_app(). I am using the shinyserver file function golem::add_shinyserver_file().

  3. Initiate renv with renv::init(), isolate and restore with renv::isolate() and renv::restore() respectively.

Session Info

R version 4.3.2 (2023-10-31)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 22.04.4 LTS

Matrix products: default
BLAS:   /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 
LAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.20.so;  LAPACK version 3.10.0

locale:
 [1] LC_CTYPE=en_GB.UTF-8       LC_NUMERIC=C               LC_TIME=en_GB.UTF-8        LC_COLLATE=en_GB.UTF-8    
 [5] LC_MONETARY=en_GB.UTF-8    LC_MESSAGES=en_GB.UTF-8    LC_PAPER=en_GB.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C             LC_MEASUREMENT=en_GB.UTF-8 LC_IDENTIFICATION=C       

time zone: Etc/UTC
tzcode source: system (glibc)

attached base packages:
[1] stats     graphics  grDevices datasets  utils     methods   base     

loaded via a namespace (and not attached):
 [1] config_0.3.2         rappdirs_0.3.3       utf8_1.2.4           renv_1.0.5           stringi_1.8.3       
 [6] rematch_2.0.0        digest_0.6.35        magrittr_2.0.3       attempt_0.3.1        golem_0.4.1         
[11] pkgload_1.3.4        fastmap_1.1.1        rprojroot_2.0.4      jsonlite_1.8.8       processx_3.8.4      
[16] parsedate_1.3.1      pkgbuild_1.4.4       sessioninfo_1.2.2    whoami_1.3.0         rcmdcheck_1.4.0     
[21] urlchecker_1.0.1     ps_1.7.6             promises_1.2.1       httr_1.4.7           purrr_1.0.2         
[26] fansi_1.0.6          cli_3.6.2            shiny_1.8.1          rlang_1.1.3          crayon_1.5.2        
[31] ellipsis_0.3.2       withr_3.0.0          remotes_2.5.0        cachem_1.0.8         yaml_2.3.8          
[36] devtools_2.4.5       tools_4.3.2          uuid_1.2-0           memoise_2.0.1        httpuv_1.6.14       
[41] curl_5.2.1           assertthat_0.2.1     vctrs_0.6.5          rhub_1.1.2           R6_2.5.1            
[46] mime_0.12            lifecycle_1.0.4      stringr_1.5.1        fs_1.6.3             htmlwidgets_1.6.4   
[51] xopen_1.0.0          usethis_2.2.3        haliTest4_0.0.0.9000 miniUI_0.1.1.1       desc_1.4.3          
[56] callr_3.7.6          pillar_1.9.0         later_1.3.2          rsconnect_1.2.1      glue_1.7.0          
[61] profvis_0.3.8        Rcpp_1.0.12          rstudioapi_0.16.0    xtable_1.8-4         htmltools_0.5.7     
[66] compiler_4.3.2       prettyunits_1.2.0  

haliTest4_0.0.0.9000 is the name of the App.

log

image
@shumza-nali shumza-nali changed the title App not deploying on Shiny Server [BUG] App not deploying on Shiny Server Mar 28, 2024
@shumza-nali
Copy link
Author

@VincentGuyader @ColinFay Do you have an ideas on what could be going wrong?

@VincentGuyader
Copy link
Member

hi,

I use renv a lot, but not for shinyserver (although that shouldn't matter).
I don't quite understand the issue. What is shinyserver supposed to do with the renv.lock file? I assume you need to add renv::activate() in the app.R

Have you managed to use shinyserver + renv + a simple app.R (outside of golem, I mean)?

Regards

@shumza-nali
Copy link
Author

shumza-nali commented Mar 28, 2024

Many thanks for your response @VincentGuyader

My company has a new server. The old server would not deploy the App until I used renv (then it worked for the golem app).

When I add renv::activate() in app.R and run the app with shiny::run_App() I get the error below, and it restarts the R session and loads my project.
Error in func(fname, ...) : app.R did not return a shiny.appobj object.

I can say the following after further testing:

  1. shinyserver + simple app.R deploys (new project -> new directory -> Shiny application)
  2. shinyserver + simple app.R + external package does not deploy
  3. The same as # 2 + renv deploys (renv::init() and renv::isolate()).
  4. shinyserver + golem app does not deploy
  5. shinyserver + golem app + renv does not deploy. Worth noting for renv::snapshot() I am choosing the explicit mode (from DESCRIPTION file) with the following as Imports:
Imports: 
    config (>= 0.3.2),
    golem (>= 0.4.1),
    pkgload,
    shiny (>= 1.8.0)

Many thanks

EDIT:

Another interesting observation:

shinyserver + simple app.R + renv with library(golem) in app.R. Once I call renv::snapshot() and renv::isolate(), the deployed app works. So I don't think there is an issue with the dependency of the App, rather the way the golem framework deploys the app.

@shumza-nali
Copy link
Author

shumza-nali commented Apr 3, 2024

@VincentGuyader I think I have found the source of the bug. You should be able to reproduce this.

THE BUG: when initiating renv inside a golem project an renv folder is created inside the project without a library.

Instead, the library is created in the cache directory '/home/myuser/.cache/R/renv/library/myproject'. This does not happen with a simple shiny app.R (outside of Golem).

This leads me with two questions:

  1. Is there any way to force renv to not use the cache?
  2. Why does this happen only with Golem?

Many thanks

@shumza-nali
Copy link
Author

rstudio/renv#384 (comment)

Found the answer here. I had to specify my RENV_PATHS_LIBRARY in project .Renviron.

I wonder why I had to do this in the first place? Why was this not the default and the .cache directory was?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants