Set Pandoc Location

Is it possible to set Pandoc's location when executing rmarkdown::render?

It looks like the method that "finds pandoc" accepts a parameter "dir" that intends to do this, but I don't see anywhere to provide a value

from source:
find_pandoc <- function(cache = TRUE, dir = NULL, version = NULL)

Pandoc location is cached for render to find it. find_pandoc is used to select the correct value to be used. So you just have to call find_pandoc before calling render. if cache = TRUE (the default), this selected version, the one returned by find_pandoc, will be used because the value have been cached and find_pandoc() by default return the cached value.

Here an example of how it works

library(rmarkdown)
# default to last version found
find_pandoc()
#> $version
#> [1] '2.10.1'
#> 
#> $dir
#> [1] "C:/Users/chris/scoop/shims"

# use one from a specified directory
# cache=FALSE is needed because one version is already cached 
find_pandoc(cache = FALSE, dir = Sys.getenv("RSTUDIO_PANDOC"))
#> $version
#> [1] '2.7.3'
#> 
#> $dir
#> [1] "C:/Users/chris/scoop/apps/rstudio/current/bin/pandoc"
# it becomes the default
find_pandoc()
#> $version
#> [1] '2.7.3'
#> 
#> $dir
#> [1] "C:/Users/chris/scoop/apps/rstudio/current/bin/pandoc"

# use a specified version
find_pandoc(cache = FALSE, version = "2.10.1")
#> $version
#> [1] '2.10.1'
#> 
#> $dir
#> [1] "C:/Users/chris/scoop/shims"
# it becomes the default
find_pandoc()
#> $version
#> [1] '2.10.1'
#> 
#> $dir
#> [1] "C:/Users/chris/scoop/shims"

Created on 2020-07-25 by the reprex package (v0.3.0.9001)

Hope it helps

2 Likes

Understood.. thank you!

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.