Search code examples
rwindowsvisual-studio-coder-markdownpandoc

"Error: pandoc version 1.12.3 or higher is required" in VSCode, but works in R Studio


I'm having trouble trying to set up rmarkdown to work within VSCode. I have tried Sys.setenv(RSTUDIO_PANDOC = "path"), but if I set it to the same path that R Studio successfully uses, if I do rmarkdown::pandoc_available() it still returns [1] FALSE.

I have also tried setting it as an environment variable in my VSCode settings.json. Again, I can knit with no problems from R Studio. I have looked at many answers to similar questions here on StackOverflow, but none of them have worked for me thus far. I am running Windows 10.

EDIT:
r$> Sys.getenv("RSTUDIO_PANDOC")
Returns
[1] "C:/Program Files/RStudio/bin/quarto/bin/tools/pandoc.exe"

I have tried running
Sys.setenv(RSTUDIO_PANDOC = "C:/Program Files/RStudio/bin/quarto/bin/tools/pandoc.exe")

My settings.json file includes this

"terminal.integrated.env.windows": { "RSTUDIO_PANDOC":"C:/Program Files/RStudio/bin/quarto/bin/tools/pandoc.exe" }

Solution

  • Add the pandoc folder to your Path environment variable:

    1. Press Windows key and type 'environment variables'. Hit Enter. This should take you to a window titled 'Environment Variables'
    2. Select 'Path' and click 'Edit...'
    3. You should see a list of paths. Click 'New' and enter C:\Program Files\RStudio\bin\quarto\bin\tools\. It should be at the bottom of the list
    4. Click 'Okay'

    This is based on https://github.com/rstudio/rmarkdown/issues/289, which I interpret as advising to use the Path environment variable rather than the RSTUDIO_PANDOC environment variable when outside RStudio.