pandoc_available from Rstudio gives a different result compared to R from a terminal

Running R from a terminal on Windows show the result below

image

However, when running the same code from Rstudio the result is TRUE

image

I hoped that pandoc_available would check if the version installed with Rstudio is available but apparently it does not, at least on Windows. Any workarounds?

Thanks

The issue here is that pandoc is bundled with RStudio.

If you call rmarkdown::pandoc_available() from the Windows terminal, R has no knowledge about the pandoc.exe in the RStudio installation.

You have two options:

  1. Install pandoc from Release pandoc 2.17.1.1 · jgm/pandoc · GitHub. This will also make sure that pandoc is available in your PATH etc...
  2. "Do it the hard way": Add the path containing the pandoc.exe binary (in your RStudio installation) to the PATHenvironment variable yourself.

Option 1 is the easiest, option 2 - though harder - will ensure you use the same pandoc versions on RStudio as well as on the Windows Terminal. The disadvantage here is that if you remove RStudio (or reinstall into another folder) pandoc is broken in the Windows Terminal.

Folder you need to add to PATH in option 2 is <installation-root>/bin/quarto/binwhere <installation-root> ist the installation directory you chose when installing RStudio.

2 Likes

Thanks @michaelmayer. R may not know about pandoc but I expected the function in rmarkdown to check for an Rstudio installation if it doesn't find pandoc on the path. If that is not feasible, I'll into the 2 options you suggested.

rmarkdown will not check for RStudio installation. It is not that easy as there could be a lot of ways and place to have a software installed. But I agree that could be done this way.
As often with external software, they most of the time add some informations like environment variable when they start, allowing other software to trigger some behavior when run in them.

rmarkdown is checking Pandoc in PATH, and also in RSTUDIO_PANDOC environment variable set by RStudio for a Pandoc binary. It will use the greater version of pandoc found.

So adding to PATH is the correct solution to use Pandoc outside of RStudio IDE.

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