Error when adding DESCRIPTION file to shinyapps.io - r

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

Related

Getting an error when trying to publish my shiny app to the server for others to view

My shiny app runs fine in my local environment, however, when I go to publish it online I get the error "An error has occurred. The application failed to start. Contact the author for more information."
When I review the error I get:
"Line 36 Paths should be to files within the project directory"
"Line 38 Paths should be to files within the project directory"
Here is the code for both of those lines:
36.
data <- read_excel("~/data/T Version/Values for R/Pricing 081021.xlsx") %>%filter(Date_of_Indication == max(Date_of_Indication))
38.
portfolio <- read_excel("~/data/T Version/Values for R/Portfolio for R 081021.xlsx")
I'm a bit stumped as to why it isn't working, any help would be much appreciated.
Thanks
The online app doesn't have access to your local directory. You need to either include the data in the code itself with something like dput() or include the URL to the raw data file via GitHub or something similar.
For example, I use code like this to read a csv from my GitHub repository for my online apps:
dat<-read.csv("https://raw.githubusercontent.com/UserName/RepoName/DataInput.csv")
But note that the repo has to be set to be publicly available (not private).
A potentially helpful link: https://shiny.rstudio.com/tutorial/written-tutorial/lesson7/

Rshiny publish error: inferAppPrimaryDoc Execution halted

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.

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.

Upload Shiny App to shinyapps.io in Showcase Mode

I'm trying to upload a Shiny App to shinyapps.io in Showcase mode. According to those directions, one includes a text file named DESCRIPTION (no extension) with the following fields (this is from the example linked above:
Title: Hello Shiny!
Author: RStudio, Inc.
AuthorUrl: http://www.rstudio.com/
License: GPL-3
DisplayMode: Showcase
Tags: getting-started
Type: Shiny
This answer describes the same process - but, it seems like it doesn't work any longer.
When I try to publish a Shiny App with a DESCRIPTION file like the one int he example, the following error is returned:
Preparing to deploy application...DONE
Uploading bundle for application: 88219...Error in readDcf(file.path(project, "DESCRIPTION"))[, "Package"] :
subscript out of bounds
Calls: <Anonymous> ... suppressMessages -> withCallingHandlers -> <Anonymous> -> unname
Execution halted
For what it's worth, I tried excluding different fields from the DESCRIPTION file, even trying one with only DisplayMode: Showcase included. I also tried saving the file in different editors.
This Google Groups thread seems to suggest this is a bug, but since there doesn't seem to be a question posted about it other than when this worked, I hoped to see if anyone had found or could suggest a fix.
EDIT: I posted an Issue on the Shiny Apps GitHub page.
Installing the latest version of packrat from GitHub (i.e., devtools::install_github("rstudio/packrat") did the trick, thanks to this GitHub Issue suggestion. Installing the latest CRAN version (install.packages("packrat")) did not work.
I open my shinyapp on the shiny server in Showcase mode using DESCRIPTION file with additional fields that were not described in documentation and it works.
Package: MyShinyApp
Version: 1.0
Title: Hello Shiny!
Author: RStudio, Inc.
AuthorUrl: http://www.rstudio.com/
License: GPL-3
DisplayMode: Showcase
Tags: getting-started
Type: Shiny
Adding fields Package and Version will resolve this error ERROR system error 71 (Protocol error) [description=Version field not found in...]

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