ThinkR-open / golem

A Framework for Building Robust Shiny Apps
https://thinkr-open.github.io/golem/
Other
904 stars 132 forks source link

golem is incompatible with shinyapps.io. Please update frontpage Readme to reflect this incompatibility. #549

Closed yogat3ch closed 3 years ago

yogat3ch commented 3 years ago

Hi @VincentGuyader & @ColinFay , We've opened a number of issues regarding deploying a golem to shinyapps.io. We haven't received much guidance on any of those issues. After running into error after error attempting to deploy the app we've spent a great deal of time converting to the golem framework, I attempted to deploy just the basic golem that is automatically created using the File > New Project > golem method in RStudio. I used the Blue button method on app.R to deploy the file. It returns the following error (which we kept encountering with the main app):

Error in value[[3L]](cond) : 
  Can't call `runApp()` from within `runApp()`. If your application code contains `runApp()`, please remove it.

It seems that the golem framework is fundamentally incompatible with shinyapps.io. The Readme should reflect this. I request that you please update the front page readme to save other shiny app developers the frustration of attempting to use this framework if they're planning to deploy to shinyapps.io, at least until the time that it becomes compatible with shinyapps.io (if it does). At present, the documentation is misleading.

statnmap commented 3 years ago

Here is a reproducible workflow I just tested with the last version available on GitHub (sha1: 06707a8bf33770bb6f08466923d06fbb4607b2cd)

Hence, it seems the {golem} framework is fundamentally compatible with shinyapps.io.

We will investigate on the other issues when possible. Thank you for your comprehension. It seems however that the last PR broke the creation from the RStudio Menu.

yogat3ch commented 3 years ago

It seems however that the last PR broke the creation from the RStudio Menu.

I had a commit from about 3 weeks ago - so I think it might have been broken for some time. I updated and created a new app via the RStudio > New Project > Create Golem workflow, and this time it worked.

So it looks like I need to diff the core golem R files to determine what is different in the golem working files between the commit I was using and the present one? Or maybe just copy all the files over except the core golem files from the app that was using the older commit?

yogat3ch commented 3 years ago

To solve this issue:

Seems to be working now! Thanks for your help @statnmap !

ColinFay commented 3 years ago

@yogat3ch there was an issue in the dev version of golem regarding shiny apps io indeed. It's been fixed in https://github.com/ThinkR-open/golem/commit/aaae5c8788802a7b4aef4df23691902a286dd964 It's been on the dev version for 2 weeks but was fixed a couple of weeks ago.

To update:

Cheers, Colin

yogat3ch commented 3 years ago

Thanks @ColinFay We had removed and re-initialized the rsconnect folder a number of times (as per the previous comment in #537. I had updated the package a number of times while attempting to fix the deployment. It was actually @statnmap saying that the Rstudio > New Project > golem had been broken in previous versions that clued me in to the real issue. The original point at which we had downloaded golem and used it to construct the golem directory had used defunct R files. I think that was the primary issue. It was super intractable because I hadn't considered that re-downloading the package wouldn't effect the way the package deploys itself - it would only affect the functions as you use them after updating.

To solve it we had to re-create the golem directory with the newest golem version, and copy everything over except run_app.R and golem-config.R into the newly created golem. That seems to have resolved the issue. The only way I can think of to avoid situations like this is something like a check_golem function that actually checks to see that the originally deployed golem has the latest version of golem's files in use and warns people when they may need to re-deploy the golem itself.

Along the way I discovered that shinyapps.io ignores the Collate field directive in DESCRIPTION. R files that are dependencies for earlier files must be renamed such that the execute earlier in the alphabetic execution order. We discovered this because the global.R file that launches app dependencies kept erroring because of missing functions. We ended up adding a 0_ prefix to the filenames for utils_helpers.R file and the utils-pipe.R (so they became 0_utils_helpers.R etc) files that were necessary to load such that global.R would run properly.

I'm not sure this is something that can be fixed but it could be worth mentioning in the Docs.

If you'd like me to open PRs for these issues (the need for check_golem or the Collate ignore needing mention in the Docs) just let me know

KasperSkytte commented 2 years ago

I found that including the DESCRIPTION file when publishing to shinyapps.io helped packrat discover how to install the app. Perhaps also run devtools::install() before