Can't upload my flexdashboard to shinyapp.io

I'm struggling to find a way to upload my flexdashboard app to shinyapp.io. It is an interactive app where I read and write docs (also use source function for example).

The rmd gets deployed, but when opening it on shinyapss.io I get the following

Error: An error has occurred. Check your logs or contact the app author for clarification.

I have tried to change path routes, start a shinyapp project, a Rproject, and so many things ...

Here is the logs from rsconnect::showLogs

2020-06-23T20:41:05.018776+00:00 shinyapps[2494849]:
2020-06-23T20:41:04.962682+00:00 shinyapps[2494849]: The following objects are masked from 'package:shiny':
2020-06-23T20:41:05.018777+00:00 shinyapps[2494849]:
2020-06-23T20:41:04.962683+00:00 shinyapps[2494849]:
2020-06-23T20:41:05.029917+00:00 shinyapps[2494849]:
2020-06-23T20:41:05.031322+00:00 shinyapps[2494849]:
2020-06-23T20:41:05.031322+00:00 shinyapps[2494849]: date, intersect, setdiff, union
2020-06-23T20:41:05.031321+00:00 shinyapps[2494849]: The following objects are masked from 'package:base':
2020-06-23T20:41:05.029918+00:00 shinyapps[2494849]: Attaching package: 'lubridate'
|.. | 2%
2020-06-23T20:41:05.029918+00:00 shinyapps[2494849]:
2020-06-23T20:41:05.035336+00:00 shinyapps[2494849]: ordinary text without R code
2020-06-23T20:41:05.030640+00:00 shinyapps[2494849]: The following object is masked from 'package:cowplot':
2020-06-23T20:41:05.018046+00:00 shinyapps[2494849]: Attaching package: 'kableExtra'
2020-06-23T20:41:05.030640+00:00 shinyapps[2494849]:
2020-06-23T20:41:05.030641+00:00 shinyapps[2494849]:
2020-06-23T20:41:05.031322+00:00 shinyapps[2494849]:
|.. | 3%
2020-06-23T20:41:05.049968+00:00 shinyapps[2494849]: Warning in file(filename, "r", encoding = encoding) :
2020-06-23T20:41:05.030641+00:00 shinyapps[2494849]: stamp
2020-06-23T20:41:05.035973+00:00 shinyapps[2494849]: label: unnamed-chunk-2
2020-06-23T20:41:05.049971+00:00 shinyapps[2494849]: no fue posible abrir el archivo 'RPS/rps.r': No such file or directory
2020-06-23T20:41:05.052159+00:00 shinyapps[2494849]:
2020-06-23T20:41:05.071180+00:00 shinyapps[2494849]: 150: source
2020-06-23T20:41:05.071185+00:00 shinyapps[2494849]: 133: knitr::knit
2020-06-23T20:41:05.035338+00:00 shinyapps[2494849]:
2020-06-23T20:41:05.071181+00:00 shinyapps[2494849]: 149: eval
2020-06-23T20:41:05.071185+00:00 shinyapps[2494849]: 132:
2020-06-23T20:41:05.051163+00:00 shinyapps[2494849]: Quitting from lines 101-290 (DashBoard.Rmd)
2020-06-23T20:41:05.071183+00:00 shinyapps[2494849]: 139: block_exec
2020-06-23T20:41:05.071186+00:00 shinyapps[2494849]: 96: origRenderFunc
2020-06-23T20:41:05.071182+00:00 shinyapps[2494849]: 142: evaluate::evaluate
2020-06-23T20:41:05.071186+00:00 shinyapps[2494849]: 110: shiny::renderUI
2020-06-23T20:41:05.071182+00:00 shinyapps[2494849]: 143: evaluate_call
2020-06-23T20:41:05.071186+00:00 shinyapps[2494849]: 111: doc
2020-06-23T20:41:05.064356+00:00 shinyapps[2494849]: Warning: Error in file: no se puede abrir la conexión
2020-06-23T20:41:05.071184+00:00 shinyapps[2494849]: 137: process_group.block
2020-06-23T20:41:05.071184+00:00 shinyapps[2494849]: 138: call_block
2020-06-23T20:41:05.071214+00:00 shinyapps[2494849]: 95: output$reactivedoc
2020-06-23T20:41:05.071183+00:00 shinyapps[2494849]: 141: evaluate
2020-06-23T20:41:05.071186+00:00 shinyapps[2494849]: 109: func
2020-06-23T20:41:05.071179+00:00 shinyapps[2494849]: 151: file
2020-06-23T20:41:05.071184+00:00 shinyapps[2494849]: 134: process_file
2020-06-23T20:41:05.071216+00:00 shinyapps[2494849]: 12: fn
2020-06-23T20:41:05.071217+00:00 shinyapps[2494849]: 7: connect$retry
2020-06-23T20:41:05.071182+00:00 shinyapps[2494849]: 148: eval
2020-06-23T20:41:05.071185+00:00 shinyapps[2494849]: 127:
2020-06-23T20:41:05.071217+00:00 shinyapps[2494849]: 6: eval
2020-06-23T20:41:05.071216+00:00 shinyapps[2494849]: 13: rmarkdown::run
2020-06-23T20:41:05.071217+00:00 shinyapps[2494849]: 5: eval
2020-06-23T20:41:05.071215+00:00 shinyapps[2494849]: 15:

And here is the line where I suppose it is failing

 source("RPS/rps.R")

But I also use the write and read functions as follows:

write_csv(tabla,"RPS/rps.csv")
tabla <- read_csv("RPS/rps.csv")

I know the problem may be because of this. Here is the call to my directory where I have developed the app.

getwd()
[1] "/Users/albtorval/Documents/Aprendizaje/Trabajos/IAJuegos"

I want to change it to

setwd("~/Documents/Aprendizaje/Trabajos/JuegosIA")

But I can't. What else can I try? Should I desist?

Perhaps try running:

source("RPS/rps.R") with the capital R

1 Like

on shinyapp.io, as you are no longer in your file system, how can you guarantee where you will be with a setwd() etc ?
you should expect that your wd is set for you; getwd() is the folder that the shinyapps.io platform accepted your code and data to. everything should be relative to that. you should use file.path() to construct the route from getwd() to your item of interest (but you also need to be confident that the item got loaded by rsconnect and so exists there).

1 Like

Wish it was that... Thanks for the reply

Already tried to indicate all my paths with file.path to the directory /Users/albtorval/Documents/Aprendizaje/Trabajos/IAJuegos and to ~/Documents/Aprendizaje/Trabajos/JuegosIA but either way is working. Thanks for the reply.

does your code rely on data NOT in its subdirectories, but in other parallel path of your file tree ?
that would of course not work on someone else PC, which is what you should conceptualise shinyapps.io as.
put your code and data, in the directory of your app code, or in an immediate subdirectory.
Then you have a chance.

1 Like

Instead of doing that, try to set your working directory to /Users/albtorval/Documents/Aprendizaje/Trabajos/IAJuegos/RPS (or wherever the RPS folder is, basically set the working directory to the RPS folder) by using setwd()

Then, when you publish to shinyapp.io, it should set that folder to the active directory (after you check the files to be also uploaded I think), and be able to detect the files, and change your code to not have the RPS before it, like this:
source("rps.R")

Which would now not have any more subdirectories like @nirgrahamuk stated

1 Like

How can I do that? You mean, every .csv, .png, .R, etc. in the same folder? All folders where I read the data are in the main folder of the project, e.g. RPS & Poker (which is another one) both are on the IAJuegos folder.

I have several folders where I rad and write the data. You mean I should take all of them into just one directory, the main one? And how can I check all the files are uploaded? In the shinyapp.io dashboard I can't see it. Or can I?

Hmm ok, yes I see how that's not ideal. I'm actually not sure, because if you are uploading the folder with its contents I would think that the way you were originally doing this would be correct.

Fixing source("RPS/rps.R") you get the exact same error?

I don't think I'm able to help, your original post looks correct to me, but maybe I'm not enough of an expert. I still think doing what I suggested is worth a shot to confirm that method would work and that there isn't another issue, but maybe that's a waste of time.

I don't think there's an easy way to see your files on shinyapp.io other than downloading the bundle of the app from the dashboard, but again maybe I'm not enough of an expert.

1 Like

The only other solution I can think of that would probably work but be more painful, would be to upload the data to google sheets and read it from there using the excellent googlesheets4 package: https://googlesheets4.tidyverse.org/ But I realize this is not really a helpful solution here vs. getting your code to upload properly, I'm just basically saying I don't have any other ideas right now haha. For the .R file you could host it and read it through GitHub using devtools like a normal package.

1 Like

Unfortunately yes. Thanks for the reply!

1 Like

It worked! After several your idea finally worked. Someone give this man hundred bucks! Thanks again.

1 Like

Glad you were able to get it to work!

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.