mustafa00
mustafa00

Reputation: 881

Problem with directory when deploying app on shinyapps

I wrote a golem app and wanted to deploy it on the shinyapp.io. Unfortunately, every time I try to do it the following error comes up (in logs):

Warning in loadSupport(appDir, renv = sharedEnv, globalrenv = NULL) : Loading R/ subdirectory for Shiny application, but this directory appears to contain an R package. Sourcing files in R/ may cause unexpected behavior.

All files related to my project are stored in one directory, where my golem project was initially created. I also checked and set manually working directory to 'R' folder (where app_server and app_ui are stored). Unfortunately when I deploy my app the mentioned error comes up again. Moreover, every time I close my project in RStudio I save workspace image to '.RData' file (this file is also stored in main directory) - maybe here is a problem (but I also tried to deploy w/o this file and it failes either). I really don't know where the problem lies and what this error means.

Interestingly, regular (single) app.R can be deployed on shinyapps without a problem.

Upvotes: 4

Views: 2475

Answers (1)

Leonardo Hansa
Leonardo Hansa

Reputation: 334

Since Shiny 1.5, if you run a shiny app with a subdir called R/, it will load every function stored in it automatically. You can avoid this setting the autoload option to FALSE, doing:

options(shiny.autoload.r=FALSE)

What I do (I'm not sure whether it is best practice) is setting that up just before calling shiny::runApp(). For intance, I usually have a launch() function in my package, which calls shiny::runApp(). Including the option within this launch() function should fix the issue.

Nonetheless, the message is a warning, not an error, and it is possible that everything is working properly in your shiny app.

Upvotes: 7

Related Questions