pandoc version 1.12.3 or higher is required and was not found (R shiny)

Another option so that this works for all your R scripts is to define this variable globally.

On Debian/Ubuntu, add the following line to your .bashrc file:

export RSTUDIO_PANDOC=/usr/lib/rstudio/bin/pandoc

On macOS, add the following to your .bash_profile file:

export RSTUDIO_PANDOC=/Applications/RStudio.app/Contents/MacOS/pandoc

On Windows (using Git Bash), add the following to your .bashrc file:

export RSTUDIO_PANDOC="/c/Program Files/RStudio/bin/pandoc/"

The easiest way I solved this issue is to pass the Sys.setenv(..) command inside the crontab command prior to calling the RMarkdown::render. You need to separate the two commands with a semicolon:

R -e "Sys.setenv(RSTUDIO_PANDOC='/usr/lib/rstudio-server/bin/pandoc'); rmarkdown::render('File.Rmd', output_file='output.html')"

(Remember that the rstudio-server path differs from the non-server version)


Go into RStudio and find the system environment variable for RSTUDIO_PANDOC

Sys.getenv("RSTUDIO_PANDOC")

Then put that in your R script prior to calling the render command.

Sys.setenv(RSTUDIO_PANDOC="--- insert directory here ---")

This worked for me after I'd been struggling to find how rmarkdown finds pandoc. I had to check github to look at the source.