Rshiny publish error: inferAppPrimaryDoc Execution halted - r

I created an Rshiny APP on my Mac and tried to upload to shinyapps.io
However, when I press 'Publish' button at the top right corner, it shows an error.
Preparing to deploy application...DONE
Uploading bundle for application: 609021...Error in inferAppPrimaryDoc(appPrimaryDoc = appPrimaryDoc, appFiles = appFiles, :
Application mode static requires at least one document.
Calls: <Anonymous> ... withStatus -> force -> bundleApp -> inferAppPrimaryDoc
Execution halted
This problem has been solved. See the first answer.
But now, I have another problem.
I can publish it, but the app cannot show the graphs.
I check the log and it says,
Warning: Error in : Aesthetics must be either length 1 or the same as the data (1): x, y, label, vjust, fill
Also, there is another warning,
Warning in Ops.factor(Year, start) : ‘>=’ not meaningful for factors.
It is pretty strange because when I run the app on my own laptop, it works super well. Please help...
Thanks,
Weichen

You don't have to split your code to ui.R and server.R.
Here is how I solved it on Rstudio:
I created a new Shiny app.R file.
This creates a new folder inside the working directory. I copied all data files I use inside my app into that folder.
I copied and pasted my whole code into the new app.R file on Rstudio.
I clicked Publish and I chose all the data files I use together with the app.R for upload.
It worked. I am not sure why it wasn't working before even though I was still choosing the right files together; I guess because they weren't in the right folder for the Shiny app.
edit: don't forget to Save the app.R file before publishing

Solved.
At first, I simply execute the shiny.R (the whole code) Wrong!
Try this. Create two r files under the same directory.
ui.R
server.R
and then executive shiny.R
You would see an amazing thing happen.

Solved the second problem.
Change the type of 'Year' to numeric by as.numeric
However, I still cannot understand because I can run app on my own laptop.
BTW, the logs in shinyapps.io help me target the problem.

Related

sharing shiny app with renv throws error due to bslib

I wanted to make internally sharing/locally launching a shiny app developed with the {golem} framework a little more robust.
Hence, I used the renv package and installed the shiny app as a local package into a project folder.
I proceeded as follows (thanks #Kat for the suggestion):
initialize renv using renv::init(bare = TRUE)
renv::install("my_local_package")
renv::snapshot(type = "all")
renv::isolate()
Writing a launch file consisting of:
library(golempackage)
renv::restore()
golempackage::run_app(options = list(launch.browser = TRUE))
Share folder.
However, when launching the shiny app on a different computer (or a docker testing environment), I get the following error caused by the package bslib. Same happens when I delete my cache:
An error has occurred!
File attachments must exist: 'C:/Users/XYZ/AppData/Local/R/cache/R/renv/cache/v5/.../bslib/lib/bs3/assets/fonts'
Note: this error even occurs if I set the cache to be project-local and share it inside the project folder.
However, now the error message does not reference the global but the project-local cache. Unfortunately still as an absolute path which throws an error for other users.
This is all super weird and I have not the slightest idea why this occurs.
I would like to avoid removing bslib.
As far as I can see, the error is coming from the sass package, e.g.
https://github.com/rstudio/sass/blob/f7a954027447dd0b9826ec01c7084c89a6e64fcc/R/layers.R#L442-L443
While I don't know exactly know what's going on, you could probably use the R debugger to check why that's failing. (Does the referenced folder exist in both cases? Are you expecting renv to be using the cache in the second case?)

Error in shinytest. Cannot detect my script is a R file

I am trying to test an shiny application with the function shinytest.
I have made an record and get a new file:
The picture show my test file and how I have specified the path to my application
When I try to run the app I get the following error:
Error in is_rmd(path) :
Unknown whether app is a regular Shiny app or .Rmd: C:/Users/LUCBA/Projects/markt_to_marketpricingtool/test/myshinyapp.R
I know the file is an R file, but I get the error anyway.
Why is this happening and what can I do to fix it?
Best Lucas
This was the code that caused an error in Lucas's original question
app <- ShinyDriver$new("C:/Users/LUCBA/Projects/markt_to_marketpricingtool/test/myshinyapp.R")
The problem is that the first (path) argument to shinytest::ShinyDriver$new can only be a directory (containing either an app.R file or a server.R/ui.R pair) or R markdown .Rmd file. Sadly, a Shiny app file cannot be specified directly by name, so it can't be named myshinyapp.R.

gzfile error when publishing Shiny app

I'm trying to publish an R Shiny app. It works when run locally, but once published to shinyapps.io produces the following error.
Warning in gzfile(file, "wb") :
cannot open compressed file '/key.rda', probable reason 'Permission denied'
Error in value[[3L]](cond) : cannot open the connection
Calls: local ... tryCatch -> tryCatchList -> tryCatchOne -> <Anonymous>
Execution halted
You can also see the actual page with the error here: https://povertylab.shinyapps.io/ACS-Map-Dashboard/
Though I have tried to reproduce this error it doesn't appear when I publish other apps, and my searches haven't turned up anything. Other things I've tried: publishing from other computers, publishing only global.R, server.R, and ui.R files, and copying files to a new project and publishing from there.
You can find all code for the app here: https://github.com/Poverty-Lab/ACS-Map-Dashboard
I would appreciate any input, even if it's just guidance on what gzfile is and what the error message could mean. Thank you!
Where is the key.rda file supposed to be? I've looked through your repo and I don't see it, which is probably causing the "cannot open the connection" error.
As a side note, you should probably ignore the .Renviron file; right now anyone can use see and use your key. Make sure you remove it from the history as well.
Thanks all. Turns out this was a problem with the way we were handing the api key for the acs package. We were using api.key.install to install the api key inside the app, and one of api.key.install's default arguments is file = "key.rda", and that file apparently could not be found. I'm still not sure why this problem only came up when we published the app, but we got around it by supplying the actual api key to the acs.fetch function in server.R.

Error when adding DESCRIPTION file to shinyapps.io

recently I wanted to enable the Showcase mode on my Shiny app, which I uploaded to shinyapps.io. I looked at some other questions in this forum and created a DESCRIPTION file (no file extension) that looks like this:
Title: XX
Author: YY
DisplayMode: Showcase
Type: Shiny
As soon as I want to upload my App together with the Description file (using either the "publish" button provided by RStuio or using the "shinyapps::deployApp("XX",account="yy")" command), I get the following error (99999 is an edited number):
Preparing to deploy application...DONE
Uploading bundle for application: 99999...Error in readDcf(file.path(project, > "DESCRIPTION"))[, "Package"] :
subscript out of bounds
Calls: ... suppressMessages -> withCallingHandlers -> -> unname
Execution halted
I also tried adding/removing lines from the DESCRIPTION file, including the DisplayMode line, but it didn't help. Uploading the App without the Description file still works fine. Furthermore I completely uninstalled R and RStudio and reinstalled the newest versions (3.2.3 and 0.99.879). I am using Windows 10.
Also the app works fine and is in Showcase mode if I run it locally.
Any ideas what this could be about?
Thank you so much in advance,
Laurin

Shiny App Error: /v1/applications/ 400 - Validation Error Execution halted

Hi I'm having a million problems trying to publish my app to shiny.io.
Firstly, I have Rtools 3.2 installed in my computer and set to the Path, but it is not recognized in the registry. Nevermind, this code should fix it:
install.packages("installr")
library(installr)
install.Rtools(choose_version = FALSE, check = TRUE, use_GUI = TRUE,
page_with_download_url = "http://cran.r-project.org/bin/windows/Rtools/, keep_install_file=TRUE")
install.packages("devtools")
library(devtools)
devtools::install_github('rstudio/shinyapps')
Next, to deploy my app to my shiny.io account:
library(shinyapps)
shinyapps::setAccountInfo(name='xxxx', token='xxxxxxxxxx', secret='xxxxxxxx')
Then my app starts running in a browser, and I click publish to my shiny account. However, when the app is being deployed, it shows the following error:
Preparing to deploy application...Error: /v1/applications/ 400 - Validation Error
Execution halted
Any ideas what the problems may be? Thank you.
I had the same error returned. In my case the problem was the name of the app itself. Deployed apps must have names at least 4 characters long with no spaces.
Setting an application name solved this problem for me. My application directory contained a space.
deployApp(appName = "myapp")
I had the same problem, however, my app name was fine and even adding 'appName =' did not help. Just a side note that this issue came up because I changed the name of my folder in effort to change the name of my app in shinyapp.io
The only thing that worked for me is publishing through the "Publish" button of Rstudio on upper right. I would recommend publishing using that instead of command. You can select files you do not want to publish within the App folder and you can publish the app under a different name then your local name.
I also had similar errors and the issue was resolved after I changed the name of the directory that holds the "app.R" file from only 3 characters to more than 4 characters.

Resources