Running script from bat file - saveWidget function requires pandoc Error

Hey, I have a similar problem as here:
saveWidget function in an old script - R Markdown - Posit Community (rstudio.com)

The difference is, that I have pandoc installed and when I am running my shiny app via RStudio, there is no issue, everything works as intended.

But when I am running the script through a bat file shortcut, I get the error from the browser: "Couldn't download, something went wrong..."
And in the logs its stating: "Warning: Error in pandoc_self_contained_html: Saving a widget with selfcontained = TRUE requires pandoc. See here to learn more 1.1 Use a Pandoc version not bundled with the RStudio IDE | R Markdown Cookbook
1: shiny::runApp"

The application:

library(shiny)
library(ggplot2)
library(plotly)
library(htmlwidgets)
  
  ui <- fluidPage(
    downloadButton("downloadData", "Download")
  )
  
  server <- function(input, output) {
    data <- mtcars
    
    plot1 <- ggplot2::ggplot(mtcars, aes(x = cyl, y = hp))+
      geom_point()
    
    plot <- ggplotly(plot1)
 
    output$downloadData <- downloadHandler(
      filename = function() {
        paste("data-", Sys.Date(), ".html", sep="")
      },
      content = function(file) {
        htmlwidgets::saveWidget(plot, file, selfcontained = T)
      }
    )
  }
  
  shinyApp(ui, server)

And my bat file:

"C:/Program Files/R/R-4.2.0/bin/R.exe" -e "shiny::runApp('C:/Users/user/Desktop/Download.R', launch.browser = TRUE)"

Many thanks

Found the answer only a few minutes after I posted this...

r - How to address the pandoc issue - Stack Overflow

So I just used

rmarkdown:::find_pandoc()

And then added/copy pasted the path to paths, using this tutorial:
What is Windows PATH and How Do You Add to and Edit it? - Make Tech Easier

Now everything works as intended.
Cheers

This topic was automatically closed 54 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.