Creating selfcontained html file within shinyproxy

I am using saveWidget to save a leaflet map as a standalone html file. This works fine locally in RStudio, but when I deploy to the shinyproxy server, it fails. Its not related to writing to the file location as to create txt files or a non-selfcontained html file works fine.

Does anyone have experience with this issue?

Here’s a bit of code to reproduce the issue:

map <- leaflet() %>% addTiles(options = list(minZoom = 2, maxZoom = 18)) %>% addProviderTiles(providers$OpenStreetMap)

saveWidget(widget=map, file="./map_test1.html", selfcontained = FALSE)
saveWidget(widget=map, file="./map_test2.html", selfcontained = TRUE)

Hi Luca,
Looking at the code for saveWidget, it uses pandoc in case of selfcontained = TRUE, so maybe the issue is that you don’t have pandoc installed inside your docker image.
If this doesn’t help, could you please indicate what is the error you get?

Hi Maxim

We do have pandoc installed in the docker image. The error message is:

pandoc: Could not find data file map_test2_files/leaflet-0.7.7/
Error: pandoc document conversion failed with error 97

Thanks for providing the error message.
One other thought I have is that it might have to do with the file extension: compare output of
saveWidget(widget=map, file="./map_test2", selfcontained = TRUE) and saveWidget(widget=map, file="./map_test2.html", selfcontained = TRUE)
The first one is not a valid html document, since pandoc (called by saveWidget) doesn’t know that you want HTML and generates markdown by default.
Why it works on your local machine is not clear, but maybe you have different versions of R packages and/or pandoc compared to the shinyproxy server.

You are right, it should be .html, it was just missing after I simplified the code for having a reproducible example, I’m sorry about that!

However, the issue still persists even after adding .html.

Unfortunately, I am not able to reproduce the issue with the example from your first post - in a dummy shiny application that would run the code after clicking a button the file gets created fine.
Do you experience the same issue if you launch the docker container outside of the shinyproxy? (with docker run ...)

Yes, I do see the same issue when I launch the docker container. Unfortunately, I’m not able to reproduce the error in R Studio either. I only face the issue on the server where we use shinyproxy…

FYI I actually did the test above inside shinyproxy.

I would also try to replicate your local setup in the shinyproxy in terms of versions of R, R packages and pandoc.
Another thing to try is to run R interactively inside the docker container and debug the saveWidget call to see where it fails, which would be the call to pandoc I presume, but then investigate the filesystem and try to understand why the file mentioned in the error message is not there…

Thanks for your input. I did further tests, however, none of them helped me fixing the issue. The failure is definitely within the pandoc command, more specifically it fails when doing the system command for pandoc within htmlwidgets:::pandoc_convert().
Since the issue seems to be related to saveWidget() and notto shinyproxy, I have now opened the issue within htmlwidgets: