I am trying to publish a new version of my golem Shiny app (eneRgyVD) on shinyapps.io which is working perfectly fine locally using run_app()
, but not when published :
I am facing a very generic error after deployment when reaching the app's url:
The application failed to start.
exit status 1
GitHub repo to the app here : eneRgyVD
Investigating the logs I find these last lines (previous ones are not shown but relate to package versions) :
2022-11-11T17:10:31.511128+00:00 shinyapps[7600048]: Shiny application starting ...
2022-11-11T17:10:31.522405+00:00 shinyapps[7600048]: Warning in loadSupport(appDir, renv = sharedEnv, globalrenv = NULL) :
2022-11-11T17:10:31.522424+00:00 shinyapps[7600048]: Loading R/ subdirectory for Shiny application, but this directory appears to contain an R package. Sourcing files in R/ may cause unexpected behavior.
2022-11-11T17:10:32.079655+00:00 shinyapps[7600048]: ℹ Loading eneRgyVD
2022-11-11T17:10:36.486969+00:00 shinyapps[7600048]: Error in value[[3L]](cond) : Failed to load 'R/utils_helpers.R'
2022-11-11T17:10:36.487013+00:00 shinyapps[7600048]: Calls: local ... tryCatch -> tryCatchList -> tryCatchOne -> <Anonymous>
2022-11-11T17:10:36.487018+00:00 shinyapps[7600048]: Execution halted
2022-11-11T17:10:36.487021+00:00 shinyapps[7600048]: Shiny application exiting ...
I have no clue why it cannot read this utils_helpers.R
file, everything seems quite normal to me in it...
Investigating the Deploy tab in RStudio, I find this :
Deployment completed: https://dge-diren.shinyapps.io/eneRgyVD_testing/
Message d'avis :
Error detecting locale: Error in read.table(file = file, header = header, sep = sep, quote = quote, : ligne finale incompl�te trouv�e par readTableHeader dans 'raw'
(Using default: en_US)
This confuses me since I do not use any read.table
function in my whole app, nor do I read any .csv
file directly, I'm only loading .rda
files and reading one .json
file from utils_helpers.R
...
I'm running with shiny_1.7.2
and golem_0.3.3
. Looking for solutions I explored multiple leads :
Making sure I have a _disable_autoload.R
file in my R/
sub-directory
Adding options(shiny.autoload.r=FALSE)
: no effect (as expected due to the last step)
Checking dependencies imports in all my module files and app_ui/server.R
files
Disconnecting/reconnecting my shinyapps.io account from RStudio
Copy/pasting all files except .RProj
in a new directory and trying to publish again
Various other small unsuccessful tweaks after looking on so many threads...
Any help would be absolutely fantastic. I need to deploy this app for my work, and hours of debugging did not make any difference here.
The app is fairly complex, but since it's working locally I'm not sure the problem lies in the code directly.
Thanks for any ideas !
EDIT: here's my sessionInfo()
output as well :
R version 4.1.2 (2021-11-01)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19044)
Matrix products: default
locale:
[1] LC_COLLATE=French_Switzerland.1252 LC_CTYPE=French_Switzerland.1252 LC_MONETARY=French_Switzerland.1252
[4] LC_NUMERIC=C LC_TIME=English_United States.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] shiny_1.7.2 eneRgyVD_0.0.0.9000
loaded via a namespace (and not attached):
[1] colorspace_2.0-3 rjson_0.2.21 ellipsis_0.3.2 class_7.3-20
[5] rsconnect_0.8.27 leaflet_2.1.1 rprojroot_2.0.3 fs_1.5.2
[9] rstudioapi_0.13 proxy_0.4-27 farver_2.1.1 roxygen2_7.2.1
[13] remotes_2.4.2 DT_0.23 golem_0.3.3 fansi_1.0.3
[17] xml2_1.3.3 cachem_1.0.6 knitr_1.39 config_0.3.1
[21] pkgload_1.3.0 jsonlite_1.8.0 shinydashboard_0.7.2 readr_2.1.2
[25] compiler_4.1.2 httr_1.4.3 assertthat_0.2.1 fastmap_1.1.0
[29] lazyeval_0.2.2 cli_3.3.0 later_1.3.0 s2_1.1.0
[33] prettyunits_1.1.1 htmltools_0.5.3 tools_4.1.2 gtable_0.3.1
[37] glue_1.6.2 dplyr_1.0.9 wk_0.6.0 Rcpp_1.0.9
[41] jquerylib_0.1.4 vctrs_0.5.0 writexl_1.4.0 crosstalk_1.2.0
[45] ggalluvial_0.12.3 xfun_0.31 stringr_1.4.0 ps_1.7.1
[49] brio_1.1.3 testthat_3.1.4 miniUI_0.1.1.1 mime_0.12
[53] lifecycle_1.0.3 devtools_2.4.4 shinycssloaders_1.0.0 scales_1.2.0
[57] fresh_0.2.0 ragg_1.2.2 hms_1.1.1 promises_1.2.0.1
[61] thematic_0.1.2.1 curl_4.3.2 yaml_2.3.5 memoise_2.0.1
[65] ggplot2_3.4.0 sass_0.4.2 stringi_1.7.8 desc_1.4.1
[69] attachment_0.2.5 e1071_1.7-11 leaflet.extras_1.0.0 pkgbuild_1.3.1
[73] attempt_0.3.1 rlang_1.0.6 pkgconfig_2.0.3 shinydashboardPlus_2.0.3
[77] systemfonts_1.0.4 evaluate_0.15 fontawesome_0.3.0 purrr_0.3.4
[81] sf_1.0-8 labeling_0.4.2 htmlwidgets_1.5.4 processx_3.7.0
[85] tidyselect_1.2.0 here_1.0.1 magrittr_2.0.3 R6_2.5.1
[89] profvis_0.3.7 generics_0.1.3 DBI_1.1.3 pillar_1.8.1
[93] withr_2.5.0 units_0.8-0 tibble_3.1.8 crayon_1.5.1
[97] shinyWidgets_0.7.1 uuid_1.1-0 shinyalert_3.0.0 bs4Dash_2.1.0
[101] KernSmooth_2.23-20 utf8_1.2.2 plotly_4.10.1 urlchecker_1.0.1
[105] tzdb_0.3.0 rmarkdown_2.14 usethis_2.1.6 grid_4.1.2
[109] data.table_1.14.2 callr_3.7.1 forcats_0.5.1 digest_0.6.29
[113] classInt_0.4-7 xtable_1.8-4 tidyr_1.2.0 httpuv_1.6.5
[117] textshaping_0.3.6 openssl_2.0.2 munsell_0.5.0 viridisLite_0.4.0
[121] bslib_0.4.0 sessioninfo_1.2.2 askpass_1.1
EDIT 2 : I have launched a quite older version of the app, and it works perfectly fine, with the same warning in the Deploy tab (about read.table
). So it seems it's something directly inside utils_helpers.R
which I cannot figure why... So I'm isolating every bit of code since the last version, and try to publish at every step until something goes wrong... Pity me :-)
After hours of debugging and trying to isolate the issue, I eventually found that using variable names with spaces and/or accents was the cause of all these problems.
So for instance using data$'Catégorie DIREN'
(with backticks instead of quotes) was working perfectly fine locally, but not for shinyapps, probably due to locale setting that I don't know much about.
So what I did was changing all non-ASCII column names to ASCII (-> data$categorie_diren
) and to nicely display these columns inside the tables of my app, I created a make_fr_colnames()
function, adding accents, spaces, etc. where needed.
Now everything works perfectly. I'm leaving this question in case of anyone encounters the same issue. Unfortunately the errors raised by logs and Deploy tab were quite uninformative. This will teach me to check my package before trying to publish it, because non-ASCII warnings were raised at this step.