Leaflet map working in local Shiny but 'Couldn't normalize path' error on shinyapps.io


I am relatively new to R Shiny, but have used R for some time.

My app displays a choropleth on a leaflet map, which displays without issue when running the app locally. But when I deploy to shiny.io, then in-place of the map I receive the error:
"Error: An error has occurred. Check your logs or contact the app author for clarification."

The related lines of the log appears to be:

"2019-07-18T19:16:52.455061+00:00 shinyapps[1040063]: Listening on
2019-07-18T19:16:57.337731+00:00 shinyapps[1040063]: Warning: Error in value[[3L]]: Couldn't normalize path in addResourcePath, with arguments: prefix = 'leaflet-providers-1.1.17'; directoryPath = 'C:/Users/ucesmac/Documents/R/win-library/3.6/leaflet/htmlwidgets/lib/leaflet-providers'
2019-07-18T19:16:57.345470+00:00 shinyapps[1040063]: 109: transform
2019-07-18T19:16:57.345470+00:00 shinyapps[1040063]: 108: func
2019-07-18T19:16:57.345471+00:00 shinyapps[1040063]: 106: f
2019-07-18T19:16:57.345472+00:00 shinyapps[1040063]: 105: Reduce
2019-07-18T19:16:57.345472+00:00 shinyapps[1040063]: 96: do
2019-07-18T19:16:57.345473+00:00 shinyapps[1040063]: 95: hybrid_chain
2019-07-18T19:16:57.345473+00:00 shinyapps[1040063]: 94: origRenderFunc
2019-07-18T19:16:57.345474+00:00 shinyapps[1040063]: 93: output$LACmap
2019-07-18T19:16:57.345474+00:00 shinyapps[1040063]: 13: runApp
2019-07-18T19:16:57.345474+00:00 shinyapps[1040063]: 12: fn
2019-07-18T19:16:57.345475+00:00 shinyapps[1040063]: 7: connect$retry
2019-07-18T19:16:57.345463+00:00 shinyapps[1040063]: 118: stop
2019-07-18T19:16:57.345476+00:00 shinyapps[1040063]: 6: eval
2019-07-18T19:16:57.345465+00:00 shinyapps[1040063]: 117: value[[3L]]
2019-07-18T19:16:57.345503+00:00 shinyapps[1040063]: 5: eval
2019-07-18T19:16:57.345467+00:00 shinyapps[1040063]: 115: tryCatchList
2019-07-18T19:16:57.345466+00:00 shinyapps[1040063]: 116: tryCatchOne
2019-07-18T19:16:57.345467+00:00 shinyapps[1040063]: 114: tryCatch
2019-07-18T19:16:57.345468+00:00 shinyapps[1040063]: 113: addResourcePath
2019-07-18T19:16:57.345468+00:00 shinyapps[1040063]: 112: FUN
2019-07-18T19:16:57.345469+00:00 shinyapps[1040063]: 111: lapply
2019-07-18T19:16:57.345470+00:00 shinyapps[1040063]: 110: renderWidget"

Searching for the string "Error in value[[3L]]: Couldn't normalize path in addResourcePath," I have read the following posts:

These posts do not refer specifically to Leaflet, but seem to point to the following issues, all of which I have checked, and are not an issue in my case: packages being placed on network drives, libraries not called from within app.r or package versioning. So I have updated all packages, restarted RStudio and redeployed to shiny.io, but am still receiving the same error.

The code is quite long so I will have to create a shorter reprex tomorrow. But for now, has anyone come across this issue, or have any insights into how I might solve it?

Thanks in advance for your help!

p.s. incase the first few lines of the log are useful:

2019-07-18T19:16:51.448348+00:00 shinyapps[1040063]: LANG: en_GB.UTF-8
2019-07-18T19:16:51.448349+00:00 shinyapps[1040063]: R version: 3.6.0
2019-07-18T19:16:51.607413+00:00 shinyapps[1040063]: Using jsonlite for JSON processing
2019-07-18T19:16:51.448352+00:00 shinyapps[1040063]: httpuv version: 1.5.1
2019-07-18T19:16:51.448303+00:00 shinyapps[1040063]: Server version: 1.7.6-6
2019-07-18T19:16:51.448362+00:00 shinyapps[1040063]: rmarkdown version: 1.13
2019-07-18T19:16:51.448689+00:00 shinyapps[1040063]: Using pandoc at /opt/connect/ext/pandoc2
2019-07-18T19:16:51.618232+00:00 shinyapps[1040063]: Starting R with process ID: '24'

Solved! In producing the ReprEx I discovered the issue:

As there are a lot of required variables for my shiny to work, I do my pre-calculations in a separate project, save the required variables in a .rdata file, which is saved in the shiny folder (i.e. same folder as app.r), and the shiny code then simply only needs to load that .rdata file. This normally works great, and greatly simplifies the shiny code (i.e. app.r) as it means that it doesn't need to do any actual precalculation and only has to read in one file to obtain all the data/variables it needs (it also makes debugging the precalculations much easier).

However, this apparently doesn't work for geospatial files (at least those read in using the 'sf' package). The problem is solved by moving the geospatial files into the shiny folder, and adding all the map calculation/preparation code into the shiny code.

If anyone knows why my original approach does not work for geospatial files then please let me know.

Still, happy it's fixed!


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