rmarkdown flexdashboard pandoc error

I use rmarkdown/flexdashboard to knit together documents as an easy way to share information - a few weeks ago, the "render()" function started producting an error. I have seen similar conversations on this topic, but can't seem to find one that answers my question.

example:

---
title: "Report Name"
output: 
  flexdashboard::flex_dashboard:
    vertical_layout: scroll
    theme: sandstone
---
    render(input = "//location//report.Rmd"
           ,output_dir = "outputlocation")
TlsExceptionHostPort (HandshakeFailed (Error_Protocol ("certificate rejected: [NameMismatch \"xx.xxx.xx.xx\"]",True,CertificateUnknown))) "WinShare" 80
Error: pandoc document conversion failed with error 67

I read on a few threads that adding "selfcontained = no" to the rmarkdown heading eliminates this problem (and indeed it does) but then I am unable to share the .html rmarkdown documents with others (does not render correctly).

They will render correctly if I open up the .Rmd document and knit it directly in RStudio - its just the "render()" command that does not work. I have 15-20 of these I knit regularly, so knitting them individually is not ideal.

1 Like

@mdwagner2 Welcome to RStudio Community!

When you run the render() command, are you running that within the RStudio R console pane, or are you running it from a separate terminal? My initial guess is that the version of pandoc being used is different in the 2 scenarios. This is because the rmarkdown package looks for the environment variable RSTUDIO_PANDOC, which by default RStudio sets to the version of pandoc that it includes.

Try running the following lines both in RStudio and before you run the render() function:

rmarkdown::pandoc_version()
rmarkdown::pandoc_exec()

Hi @jdblischak and thanks!

> rmarkdown::pandoc_version()
[1] ‘1.19.2.1’
> rmarkdown::pandoc_exec()
[1] "C:/Program Files/RStudio/bin/pandoc/pandoc"

When I knit documents or when I run the render command, I am running both in the RStudio console pane (off of desktop). I have a program with 20-30 documents that need to be knit, so I have a handful of render commands set up so I do not have to run individually.

What is odd is, some .Rmd files render fine while others do not.

1 Like

Also, not sure if this could be root cause, but the rmarkdown documents are located on a network share, along with some of the packages - could that potentially impact why versions are not aligning?

Not sure how to check/update versions on my desktop versus versions on network share.

UPDATE

Versions do match between file share and what is on my desktop of all packages used (just copied them all over to be sure).

I am getting the following error:

pandoc.exe: Could not fetch \\sharelocation\jquery.min.js
type or paste code here
1 Like

@mdwagner2 This is almost certainly the problem. Pandoc, which the rmarkdown package calls to convert knitr-generated markdown files to various formats such as HTML, has trouble with files on Windows network shares.

You can see a full discussion in rmarkdown Issue #701. I recommend trying to set intermediates_dir and output_dir to local directories, as described in this comment by @cderv.

Moved everything to my desktop/local machine - render() still not working. Will have to run manually in short run :frowning:

1 Like

@mdwagner2 That's frustrating. To confirm that I understand correctly, the R Markdown files that fail to execute using render() succeed when you click on the Knit HTML button in RStudio, right?

When you run render() locally, do you get the exact same pandoc error as before, or is there a different error message?

My next guess is that maybe the files are interfering with each other. Each time you run render(), the global environment is polluted with the variables that each file defines and also any packages it loads. Does the same R Markdown file consistently fail? If yes, what happens if you restart the R session (Ctrl-Shift-F10) and then run render() on only that file in clean R session?

Good news, I figured it out the issue for all but one program.

When I was calling the rmarkdown package, I just have been calling it from the share drive my team uses. As soon as I called that package from my local machine, most of the programs worked again - imagine that is why knitting the documents worked fine as it would be all local.

There is still one document with no external references to packages that does not run - however, I wonder if its just a size issue as it is larger (9MBish)

1 Like

Great!

I didn't even think of that. Not only having your files local, but also R and your R packages. You may have to get creative if your R installation is on a Windows share drive. Maybe RStudio Server would be a viable option?

I'm not sure what the issue could be here, but presumably it is different than the previous one you were having. Could you please copy-paste the error you got? Any chance you could create a reprex?