Search code examples
rrstudioknitrpandoc

Rstudio / pandoc issue - can't knit to HTML or PDF


I can't knit to HTML or PDF anymore, although it used to work just fine. Here's the error I keep getting:

pandoc: out of memory (requested 1048576 bytes)
Error in strsplit(version_info, "\n")[[1]] : subscript out of bounds
Calls: <Anonymous> ... pandoc_available -> find_pandoc -> lapply -> FUN -> get_pandoc_version
In addition: Warning message:
running command ''/usr/lib/rstudio/bin/pandoc/pandoc' --version' had status 1 
Execution halted

I used to have Rstudio 0.999.903, which I uninstalled, I then installed 1.0.44 version, reinstalled the knitr package through Rstudio, but I'm getting this error again.

I installed pandoc 1.18-1 from the git repository using the debian package installer, same problem again.

I later updated Rstudio to version 1.0.136 and pandoc to version 1.19.2.1 and no change.

I tried uninstalling R and re-installing a more recent version, again with no success.

The command-line works:

library(rmarkdown)
rmarkdown::render("test.Rmd", "html_document")

--

I'm using Debian (LMDE2).


Solution

  • Finally I got it!

    It seems this bug was described 2 years ago by Arch users here.

    It seems this bug was introduced for me with Rstudio version 0.98+ in a Debian system (I use LMDE Betsy).

    The pandoc version installed along with Rstudio doesn't work, and when I installed pandoc manually Rstudio would stick to using its own broken version. Anyway the workaround is to remove the executable pandoc from Rstudio distro, and symlink another version of pandoc instead:

    apt-get install pandoc
    
    rm /usr/lib/rstudio/bin/pandoc/pandoc
    ln -s /usr/bin/pandoc /usr/lib/rstudio/bin/pandoc/pandoc
    
    rm /usr/lib/rstudio/bin/pandoc/pandoc-citeproc
    ln -s /usr/bin/pandoc-citeproc /usr/lib/rstudio/bin/pandoc/pandoc-citeproc
    

    I found this workaround here.

    The repository has pandoc version 1.12, but more recent versions also work. I am now using pandoc 1.19.2.1 and Rstudio 1.0.136.