2

I have been desperately trying to deploy my shinyApp for about a week now but unfortunately I can't stop getting the following message :

Warning message: Error detecting locale: Error in read.table(file = file, header = header, sep = sep, quote = quote, : incomplete final line found by readTableHeader on 'raw' (Using default: en_US)

I took a look at the debugging Shiny app page and I used the "showcase mode" in order to try to track down the potential issues in my script. But when I run the "showcase mode" code (shiny::runApp(display.mode="showcase")) in local I get this warning message:

Warning: Error in file.path: cannot coerce type 'closure' to vector of type 'character'

As YBS explained it in the comments, this error is actually a bug in shiny but then I don't see how I can debug my script in order to deploy my app (I already tried to add an empty line at the end of each of my csv files but it didn't help)

Did someone already face this issue ?

My app: https://gitlab.com/wanderzen/shiny_app/-/blob/master/ZABR.rar

NB: my app works like a charm in local if I used shinyApp(ui, server)

Here are some info about my session :

# sessionInfo()
R version 4.0.0 (2020-04-24)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 18363)

Matrix products: default

locale:
[1] LC_COLLATE=French_France.1252  LC_CTYPE=French_France.1252    LC_MONETARY=French_France.1252
[4] LC_NUMERIC=C                   LC_TIME=French_France.1252    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] sp_1.4-1

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.4.6        BiocManager_1.30.10 compiler_4.0.0      pillar_1.4.4       
 [5] later_1.0.0         tools_4.0.0         packrat_0.5.0       digest_0.6.25      
 [9] jsonlite_1.6.1      tibble_3.0.1        lifecycle_0.2.0     lattice_0.20-41    
[13] pkgconfig_2.0.3     rlang_0.4.9         shiny_1.4.0.2       rstudioapi_0.11    
[17] curl_4.3            xfun_0.13           fastmap_1.0.1       dplyr_0.8.5        
[21] htmlwidgets_1.5.1   vctrs_0.3.0         askpass_1.1         grid_4.0.0         
[25] DT_0.16             tidyselect_1.1.0    glue_1.4.1          R6_2.4.1           
[29] purrr_0.3.4         magrittr_1.5        promises_1.1.0      ellipsis_0.3.1     
[33] htmltools_0.5.0     rsconnect_0.8.16    assertthat_0.2.1    mime_0.9           
[37] xtable_1.8-4        httpuv_1.5.2        tinytex_0.23        openssl_1.4.1      
[41] crayon_1.3.4       

# packageVersion("shiny")
[1] ‘1.4.0.2’ 
wanderzen
  • 119
  • 2
  • 12
  • Try changing your reactive object named `subset` to `subset1`. – YBS Dec 06 '20 at 15:45
  • 1
    Actually, this might be a bug in shiny. Please see [here](https://community.rstudio.com/t/error-in-file-path-when-running-shiny-apps-in-showcase-mode/70460) – YBS Dec 06 '20 at 15:59
  • Thanks for your answer YBS ! It seems indeed to be a bug... In that case I don't see any ways to check which part of my script could lead to the first error message when I try to deploy my app :/ I already tried eveything (eg: https://stackoverflow.com/questions/22171858/in-read-table-incomplete-final-line-found-by-readtableheader) – wanderzen Dec 06 '20 at 16:48
  • Could you provide your `sessionInfo()` of your local client and your deployment server. Do you have different versions of the shiny package? (following https://community.rstudio.com/t/error-in-file-path-when-running-shiny-apps-in-showcase-mode/70460/3,...) – Tonio Liebrand Dec 08 '20 at 18:51
  • Hi Tonio ! I've added some info about my session. What kind of informations do you need about my deployment server ? – wanderzen Dec 08 '20 at 19:17
  • 1
    If you follow https://community.rstudio.com/t/error-in-file-path-when-running-shiny-apps-in-showcase-mode/70460/3,... it might be the case that the problem is fixed if you upgrade to the newest shiny version. As is see you dont have the latest version of the shiny package locally. So it might be the case that your shiny package on the deployment server is also not up to date. You could try updating your package on the deployment server with `install.packages("shiny")` or even better go for the latest dev version with `remotes::install_github("rstudio/shiny")` – Tonio Liebrand Dec 09 '20 at 07:46
  • I've upgraded my shiny package to 1.5.0 but unfortunately it didn't change anything :/ – wanderzen Dec 09 '20 at 18:33
  • If you run your app from the terminal as the same user that runs your shiny apps on shiny-server, you will be able to see what the app is printing. Sometimes there are permissions differences between the rstudio user and the user that shiny-server is operating as. – da11an Dec 09 '20 at 20:22
  • 1
    If it is a problem with reading a csv, then try converting them to rds format and then read those instead. – Michael Dewar Dec 10 '20 at 16:32
  • Hi Michael ! Thanks for your suggestion but it didn't work out :'( – wanderzen Dec 10 '20 at 18:51
  • Hello, try to remove every accent and "odd" characters like "<>" you have in your code. Encodage with Shiny does not seem to work very well, so maybe the incomplete line is created by a weird " or ' inserted by bad encodage. If it works, you will have a hint on what you have to do... – Levon Ipdjian Dec 11 '20 at 13:12
  • What is the operating system of your local machine? – Waldi Dec 11 '20 at 21:24

2 Answers2

1

I guess that the problem doesn't come from Shiny but from different Locale settings between your local test machine and the Shiny server you're trying to deploy the app on.

The script you shared shows that you use six times read.csv, and the error you get looks like 'Incomplete final line' warning when trying to read a .csv file into R

First of all, I would try to use read.csv2 instead of read.csv because it is better suited for French settings, see doc :

  • separator ;
  • decimal separator ,

If this isn't enough, one of the files you're trying to load lacks an EOL on the last line.

The work around is to insert readLines into read.csv2:

read.csv2(text = readLines("yourfilename.csv", warn = FALSE),header=T) 

Waldi
  • 39,242
  • 6
  • 30
  • 78
  • Thanks for your reply Waldi ! I've already used the function ```read.table(file.choose(),header=TRUE,sep=",")``` to check if there was an issue with my csv file but I didn't get any warning message importing my file this way... I also tried your suggestion with ```read.csv2(text = readLines("yourfilename.csv", warn = FALSE),header=T) ``` but it didn't solve the problem :( – wanderzen Dec 12 '20 at 20:20
  • NB: I've added the folder containing my files here: https://gitlab.com/wanderzen/shiny_app/-/blob/master/ZABR.rar – wanderzen Dec 12 '20 at 20:55
  • Did you test the `read.csv` on your local machine or on the server? I you have the possibility to launch a R session on the server it would be useful to make sure `read.csv` finds the files and reads there without problem there. I have often had EOL surprises between text files in windows vs the same text files copied on a linux server. – Waldi Dec 12 '20 at 20:55
  • 1
    Thanks for the files, I'm going to try them on my linux shiny server : I'm going to see if I can reproduce the problem – Waldi Dec 12 '20 at 20:57
  • Awesome !! Thanks ! – wanderzen Dec 12 '20 at 21:02
  • 1
    I get not error loading the csv files on my server. Did you try to run R in console on your server? Another point I saw in `server.R`, you wrote `read.csv2(text = readLines("yourfilename.csv"), warn = FALSE,header=T)` instead of the correct syntax : `read.csv2(text = readLines("yourfilename.csv", warn = FALSE),header=T) ` – Waldi Dec 12 '20 at 21:29
  • I do not get any error neither when I load the csv files or when I run my app in local. I just can't deploy the app on the shiny server ! :/ Do you get an error while trying to deploy the app on the shiny server ? – wanderzen Dec 12 '20 at 21:35
  • I got this, but can you access the server in console mode? PuTTY on something like this? – Waldi Dec 12 '20 at 21:36
  • Sorry, I don't see what you mean by "access the server in console mode" – wanderzen Dec 12 '20 at 21:40
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/225882/discussion-between-waldi-and-wanderzen). – Waldi Dec 12 '20 at 21:42
1

It took me quite some time to debug my application fluidrow by fluidrow but I eventually found out what was causing all the trouble !

I had been using both dplyr::filter(variable== input$variable) and filter((variable == input$variable) in my script until I realized their conflict was behind the malfunction of my shiny app.

https://github.com/STAT545-UBC/Discussion/issues/331#issuecomment-249048018

wanderzen
  • 119
  • 2
  • 12