Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

rmarkdown::render() in cmd returns pandoc error

Tags:

I need to render forms with rmarkdown from a command line

this is where I am:

  • knit button in RStudio works fine
  • function rmarkdown::render(file.rmd) in a .r file works when run in Rstudio

Then I tried running this command in CMD

c:\Program Files\R\R-4.0.2\bin\Rscript.exe" -e "rmarkdown::render('C:/file.rmd')

and I get this error:

Error: pandoc version 1.12.3 or higher is required and was not found (see the help page ?rmarkdown::pandoc_available).

In RStudio I sent

> rmarkdown::pandoc_available()

[1] TRUE
> rmarkdown::pandoc_version()

[1] ‘2.7.3’

What am I missing here?

By the way, I'm on Win10.

Thanks.

like image 968
Théo Wendling Avatar asked Aug 11 '20 09:08

Théo Wendling


1 Answers

There might be an issue wit h Pandoc version, obviously. But maybe some library requires that older pandoc version, and the issue comes from you using Rmarkdown from outside Rstudio.

This link has the answer

Go into Rstudio and type

Sys.getenv("RSTUDIO_PANDOC")

Now take the output from the command above and put it here

Sys.setenv(RSTUDIO_PANDOC="OUTPUT FROM ABOVE COMMAND")

like image 187
Daniel_j_iii Avatar answered Nov 15 '22 05:11

Daniel_j_iii