Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"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" }
like image 256
Pacific Bird Avatar asked Oct 26 '25 05:10

Pacific Bird


2 Answers

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.

like image 190
andycraig Avatar answered Oct 28 '25 20:10

andycraig


Just keeping this up to date - as of RStudio build 2024.04.2 (and possibly earlier) you now need to point your path to C:/Program Files/RStudio/resources/app/bin/quarto/bin/tools.
In case it trips someone else up, you need to use RSTUDIO_PANDOC as the variable name. Restart VSCode and you should be good

like image 38
johnm Avatar answered Oct 28 '25 19:10

johnm



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!