Download of gtsave() fails on but not on local machine

Hello. I have a shiny app that downloads a gt table result that is saved using gtsave(). A snippet of the download code is shown below. The code works on my local machine on the browser, but when I publish it to my site the download fails, and in my Chrome downloads tab I see: "downloads.htm" and then in red underneath it says "Site wasn't available". The download only fails for gtsave() and not for ggsave(), as indicated in the snippet below:

output$download <- downloadHandler(
   #Note: result() is the output of an eventReactive call. It returns a list with the properties needed by the 
   #following code
    filename = result()$down_file,
    content = function(file) {
      output_type <- prep_get_function_output(input$tool_name)
      if (output_type == "plot") {
        #this works on Note that result()$plot is a ggplot object
        ggsave(file, result()$plot, 
               width = result()$width, height = result()$height)
      } else if (output_type == "gt_table") {
        #this does not work on, but it works on local host
       # note that result()$gt_table is a gt table object 
        gtsave(result()$gt_table, file)
      } else if (output_type == "table") {

I am not including the code of the eventReactive call to get 'result()' because it is long and calls some dependent functions, but I am relatively sure the problem is not there because it is working fine on my local server.

Any help is much appreciated!

Just a clarification on the above. After posting my question I checked the logs for this app and saw an error that prompted me to include the "webshot2" package. I then did this, but the error persists. I see this on my app logs on

2023-10-26T05:26:27.479062+00:00 shinyapps[10301850]: `google-chrome` and `chromium-browser` were not found. Try setting the CHROMOTE_CHROME environment variable or adding one of these executables to your PATH.
2023-10-26T05:26:27.483524+00:00 shinyapps[10301850]: Warning: Error in initialize: Invalid path to Chrome

Further clarification:

  1. my local computer runs Windows - the app works fine here.
  2. The error only occurs on the server
  3. The error occurs at the gtsave() command, it also occurs if I try this outside of the downloadHandler method

Here are what my logs show from the call to gtsave():

2023-10-26T21:28:34.370183+00:00 shinyapps[10301850]: Warning: Error in initialize: Invalid path to Chrome
2023-10-26T21:28:34.374739+00:00 shinyapps[10301850]:   239: stop
2023-10-26T21:28:34.379305+00:00 shinyapps[10301850]:   238: initialize
2023-10-26T21:28:34.384604+00:00 shinyapps[10301850]:   237: Chrome$new
2023-10-26T21:28:34.389420+00:00 shinyapps[10301850]:   236: initialize
2023-10-26T21:28:34.394679+00:00 shinyapps[10301850]:   235: Chromote$new
2023-10-26T21:28:34.400107+00:00 shinyapps[10301850]:   233: default_chromote_object
2023-10-26T21:28:34.405171+00:00 shinyapps[10301850]:   232: webshot2::webshot
2023-10-26T21:28:34.410389+00:00 shinyapps[10301850]:   231: gt_save_webshot
2023-10-26T21:28:34.414819+00:00 shinyapps[10301850]:   230: gtsave
2023-10-26T21:28:34.419768+00:00 shinyapps[10301850]:   229: prep_get_network_breakdown_nice

I have been stuck with this for a day now. Any help will be much appreciated!

I found the solution in this post:

As explained in the above link and as suggested by my error logs, the problem is that does not install Chromium or the necessary files associated with Chrome. The link above shows how to solve this.

1 Like

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

If you have a query related to it or one of the replies, start a new topic and refer back with a link.