Vypa
Vypa

Reputation: 71

Rmarkdown knit error: Fault/access violation in generated code

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.

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:

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.

Upvotes: 3

Views: 5113

Answers (2)

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/

Upvotes: 2

Bryce Chamberlain
Bryce Chamberlain

Reputation: 535

Updating pandoc fixed this for me.

https://pandoc.org/installing.html

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

Upvotes: 1

Related Questions