3
votes

I've got a particular bug in my environment such that I cannot consistently knit Rmarkdown files to HTML, Word documents, or PDFs. The ability to knit varies across by file type.

  • HTML - Sometimes it knits
  • Word document - Sometimes it knits
  • PDF - Never knits. Always throws the same error

The error is:

Segmentation fault/access violation in generated code
Error: pandoc document conversion failed with error 1

Up until a week ago, I was able to knit to all three file types in the same environment so this is a relatively recent bug. The high-level specs of my environment are:

  • OS: Windows 10
  • R: 3.4.3
  • RStudio: 1.1.419
  • knitr: 1.19
  • rmarkdown: 1.8
  • pandoc: 1.19.2.1
  • MiKTeX : 2.9

As an example of the inconsistency in the ability to knit, I crated a new .Rmd file in RStudio which creates the familiar standard template of summary(cars) and plot(pressure) etc. I didn't change anything about it. I was able to knit it successfully to HTML once, Word .docx once, and then I tried to knit to PDF and got the error above. I then went back and attempted to knit to both HTML and Word and received the error even though nothing changed from the original knit. This is just an example of the type of behavior. Different documents behave differently.

To troubleshoot, I've reinstalled R and RStudio (I believe pandoc comes up with the RStudio install so I've effectively reinstalled pandoc too). The reinstallation did not help. I've tried clearing the Knitr Cache. That didn't work either. I've browsed SO and the internet and found a few similar errors related to the Glasgow-Haskell compiler, but I have no idea what that is and if it's the source of the issue.

Here is an example of the .Rmd file that throws the error:

---
title: "Untitled"
author: "Vypa"
date: "February 8, 2018"
output:
  html_document: default
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```

## R Markdown

This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see <http://rmarkdown.rstudio.com>.

When you click the **Knit** button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:

```{r cars}
summary(cars)
```

## Including Plots

You can also embed plots, for example:

```{r pressure, echo=FALSE}
plot(pressure)
```

Note that the `echo = FALSE` parameter was added to the code chunk to prevent printing of the R code that generated the plot.

And here is the full console error:

Segmentation fault/access violation in generated code
Error: pandoc document conversion failed with error 1
In addition: Warning message:
running command '"C:/Users/Vypa/RStudio/bin/pandoc/pandoc" +RTS -K512m -RTS tst.utf8.md --to html --from markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash --output tst.html --smart --email-obfuscation none --self-contained --standalone --section-divs --template "C:\Users\Vypa\Documents\R\R-3.4.3\library\rmarkdown\rmd\h\default.html" --no-highlight --variable highlightjs=1 --variable "theme:bootstrap" --include-in-header "C:\Users\Vypa\AppData\Local\Temp\RtmpI9Gxsx\rmarkdown-str5db029544a23.html" --mathjax --variable "mathjax-url:https://mathjax.rstudio.com/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"' had status 1 
Execution halted

Any help or thoughts would be appreciated.

2
pandoc is also up to date? - elcortegano
It would help if you'd write an example of .Rmd file - elcortegano
Hi EuGENE - I would think so, since pandoc is installed with RStudio and I have the latest stable version of RStudio. I'm having trouble finding the exact pandoc version in my RStudio install, however. - Vypa
@romles I think the function is rmarkdown::pandoc_version() to get the version. pandoc_available() simply returns a boolean for me. I've edited my post to show the version of pandoc, so thanks for pointing me in that direction. - Vypa
@romles Thanks for all your help. I spoke too soon. After installing rmarkdown from github and then restarting R and RStudio, I am now able to knit all three document types. If you'd like to reply to this question, I'll mark your answer as correct. - Vypa

2 Answers

2
votes

Encountered the same problem after a recent install of R & RStudio on Win10. Pandoc problem showed up on edit and knitr of previously err free .rmd file.

Resolved after installing latest preview ver of RStudio at

https://www.rstudio.com/products/rstudio/download/preview/

1
votes

Updating pandoc fixed this for me.

https://pandoc.org/installing.html

Thanks @EuGENE. Adding here as an answer for clarity.