ThinkR-open / golem

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

Error: Unable to deploy using default arguments (multiple existing deployments from this application directory already exist). Please specify appName and/or account name explicitly. #537

Closed yogat3ch closed 3 years ago

yogat3ch commented 3 years ago

Hi @VincentGuyader & @ColinFay, This might be a noob question as this is our (myself and @kiadso) first time getting the golem framework up and running for an existing app, so please forgive me if so! We have a working golem and are attempting to deploy it We've run the commands for deploying to an RStudio platform from the dev/02_dev.R file. When attempting to run deployApp(recordDir = "log", logLevel = "verbose") from within the app directory we encounter the following error:

Error: Unable to deploy using default arguments (multiple existing deployments from this application directory already exist). Please specify appName and/or account name explicitly.
----- Deployment error -----
Error: Unable to deploy using default arguments (multiple existing deployments from this application directory already exist). Please specify appName and/or account name explicitly.
----- Error stack trace -----
Error during wrapup: length(max.lines) <= 1 is not TRUE
Error: no more error handlers available (recursive errors?); invoking 'abort' restart

Any ideas as to why this error would occur and/or how to remedy it?

VincentGuyader commented 3 years ago

Hi,

I have never encountered this error message.

2 things to be tester :

1 - can you try to launch golem::add_rstudioconnect_file() then deployApp in a brand new golem ?

2 can you in your current golem folder delete every rsconnect folder an try again ?

Regards

ColinFay commented 3 years ago

Hello,

Thanks for trying golem :)

This issue usually happens when you have deployed the same application to various places (for example, on several shiny apps io, or shiny apps and connect, or if you deploy on two endpoints on the same server but with diff names).

When trying to deploy, rsconnect tries to guess where to send the app. If it finds several places in the rsconnect folder, it will throw this error and ask you to specify exactly where to deploy it. This is what is trying to say the "multiple existing deployments from this application directory already exist). Please specify appName and/or account name explicitly." specifically.

One way to solve this is to redo the deployment, by removing the rsconnect folder from the golem project and restart.

You can also redo the deployment by specifying arguments in the rsconnect::deployApp() function :)

Let us know how it goes!

Colin

yogat3ch commented 3 years ago

Ok, will do! We've deleted rsconnect and modified the package name to be consistent across all instances (as we changed it in one place but not all after golemizing the shiny app).

I think this resolved the issue about deployment, but we can't know for sure because we are snagged on getting the app to pass devtools::check.

The issue we're having involves dependencies for the tests that app_ui needs to run that come from an RData file in the data directory. I've created a helper-tests.R file in the tests directory and confirmed that it's properly loading all the dependencies before executing tests, but these variables initialized by the helper don't appear to actually be available to the first test that runs app_ui. Are there some best practices regarding how to make data dependencies available to the golem recommended tests such that they run correctly? Would you like me to create a new issue for this discussion?

kiadso commented 3 years ago

Hi @ColinFay and @VincentGuyader thanks for helping with the rsconnect issue. We're using app_prod() to conditionally run global.R, but the options(golem.app.prod = TRUE) in the app.R file does not set it to TRUE. Nor does changing the golem-config.yaml to "yes" for production. We added a message to global.R that tells us if app_prod is true or false and it keeps coming out FALSE. This is causing global.R to not run on shinyapps.io. How do we make app_prod return TRUE on shinyapps.io? Thanks!

yogat3ch commented 3 years ago

So we got around the golem::app_prod() issue by setting global.R to run when a shinyapps.io Environment Variable is present. However we encountered another issue.

We're finding that none of the package modules or internal functions are available to the app on shinyapps.io. What is the recommended way to load the golem package on shinyapps.io inside of the app environment such that all the functions are available when the app runs? Should we just install the golem package from Github on our local machine and add the golem package to the Imports in DESCRIPTION? Or is there a better way?

yogat3ch commented 3 years ago

Should we just install the golem package from Github on our local machine and add the golem package to the Imports in DESCRIPTION? Or is there a better way?

It looks like this is not possible as R CMD check throws an error about circular dependencies. Could we receive some guidance on how to deploy a golem on shinyapps.io and have it use it's own source files? The pkgload statement in app.R does not initialize the source code in the running app likely due to the environment loading in a separate environment for which the app.R launching environment is not a parent.

Additionally, shinyapps.io is not source the files in the R folder as the error when the app tried to load global.R is that the package is unable to find one of the functions.

yogat3ch commented 3 years ago

It turns out the original version with which we deployed the golem had some defunct files, we ended up needing to update golem and re-deploy a golem and migrate everything over into the new golem.

We also discovered that shinyapps.io ignores the Collate directive in DESCRIPTION.

A full discussion can be found on #549