pandoc document conversion failed with error 127
Asked Answered
T

8

14

I'm not sure how to make a reproducible example of this, but I'm curious to hear if anyone else has encountered this problem. I have an R Markdown file hosted via shiny server on an EC2 instance running Ubuntu. Everything was working fine for days and now suddenly I get the following error when I try to view the document in the browser:

pandoc document conversion failed with error 127

I'm not converting to pdf, haven't pushed any changes, and it was working a few hours ago. I'm not finding much of anything online about this error code so I have no idea how to debug this issue. Anyone had this happen before?

Thalweg answered 8/1, 2016 at 22:16 Comment(3)
Similar bug here, using knit2pdf on a private ubuntu server. Restarting the server helped.Lemming
Yeah, I get this error a lot when multiple people are accessing a Shiny app at once. I think it's memory related.Thalweg
Getting this on a self-hosted Ubuntu VM. Definitely the memory in my case as it also says: "system call failed: Cannot allocate memory". "Error 127" is opaque and unhelpful, one is not even sure where it comes from. Well, I restarted RStudio and it worked again, so I assume memory leak (yup, first time free actually showed the swap space being used)Heated
N
6

I faced a similar issue today (see below from .log file):

Warning in system(command) : system call failed: Cannot allocate memory
Warning: Error in : pandoc document conversion failed with error 127
Stack trace (innermost first):
    105: pandoc_convert
    104: convert
    103: render
    102: discover_rmd_resources
    101: find_external_resources
    100: copy_render_intermediates
     99: output_format$intermediates_generator
     98: <Anonymous>
     97: do.call
     96: contextFunc
     95: .getReactiveEnvironment()$runWith
     94: shiny::maskReactiveContext
     93: <reactive>
     82: doc
     81: shiny::renderUI
     80: func
     79: origRenderFunc
     78: output$__reactivedoc__
      3: <Anonymous>
      2: do.call
      1: rmarkdown::run

I too am running Shiny Server via Ubuntu on an EC2 instance, specifically t2.micro. I solved this issue by following the top-voted answer here: How do you add swap to an EC2 instance?

sudo /bin/dd if=/dev/zero of=/var/swap.1 bs=1M count=1024
sudo /sbin/mkswap /var/swap.1
sudo chmod 600 /var/swap.1
sudo /sbin/swapon /var/swap.1

Add to /etc/fstab:

/var/swap.1   swap    swap    defaults        0   0

In short, you can create swap (memory) space on your EBS (since t2.micro instances don't have ephemeral storage) and this should alleviate your memory issue (without having to move up to a larger EC2 instance).

Nidify answered 25/12, 2017 at 20:40 Comment(0)
C
2

I had the same error when working with an aws EC2 instance with Ubuntu 16.04 LTS installed and running a shiny app.

My fix: I had some code outside the ui and server functions of my app.R file. I moved all outside code into the server function and the error no longer occurs.

What confused me was that the app still worked most of the time even though some of the code was outside these two functions!

Another thing you could try: Some sources state that this error occurs due to lack of memory. To aid limited memory situation on aws instances, you should provide swap space the system can use to free up memory. Ubuntu on an aws EC2 instance by default has zero swap space! You can use these instructions, google also shows plenty: http://www.thegeekstuff.com/2010/08/how-to-add-swap-space/

Chinese answered 20/6, 2017 at 12:3 Comment(0)
S
2

This happens when the RAM allocated to your R session is used up completely.

You may have memory leaks in your code.

The simplest fix is to restart the session.

Santa answered 13/7, 2017 at 9:31 Comment(0)
T
1

Hard to know for certain what you are asking without an example, but I got the same error trying to "knit to html" from an EC2 instance of RStudio.

This worked for me:

library("rmarkdown")
render("filename.Rmd", "html_document")
Truncation answered 2/2, 2016 at 22:13 Comment(0)
L
1

I know this is an old question, but as vivek mentioned, restarting the server worked for me:

sudo systemctl restart shiny-server
Langer answered 30/9, 2021 at 19:29 Comment(0)
Y
0

I got a similar error when I tried to produce a pdf_document with RStudio from a RMarkdown file. As far as I know: Error 127 means "file not found". Either the file is not there or the path is incorrect.

In my case I got the additional information, that ghostscript was not found. I had recently installed the new version of MacTex with Homebrew. But

Homebrew does … conflict with ghostscript as installed by MacTex https://github.com/Homebrew/homebrew-core/issues/11368

My solution was to create the symlink to ghostscript as suggested here: Ghostscript not writable

sudo chown -R `whoami` /usr/local/share/ghostscript
brew link --overwrite ghostscript
Yahrzeit answered 14/3, 2019 at 20:21 Comment(0)
P
0

The recommended solution is following: 1. Check where R is installed (Lets say it is C drive) 2. Make some space free in C drive from atleast 10 GB recommended 3. Happy Coding

Pickard answered 10/12, 2019 at 2:10 Comment(0)
M
0

I´m getting this error when transforming a tibble into a table with knitr::kable()

Error: pandoc document conversion failed with error 127 6. stop("pandoc document conversion failed with error ", result, call. = FALSE) 5. rmarkdown::pandoc_convert(input = rmarkdown::pandoc_path_arg(mdfile), to = "html", output = rmarkdown::pandoc_path_arg(htmlfile)) 4. print.knit_asis(knitr::asis_output(x)) 3. print(knitr::asis_output(x)) 2. print.knitr_kable(x) 1. (function (x, ...) UseMethod("print"))(x)

I´ve tryed to:

a) restart the session to refresh the memory b) install the last pandocs version

But it still does not work...

Thank you very much.

Matteo answered 7/6, 2020 at 16:1 Comment(1)
Hi Delhoyo, welcome to SO, you will have better luck if you post a new question, also you if you want to be a good SO user and receive responses you are expected to do and show some effort meta.#262092 and always format your code so it looks nice and easy to readDanner

© 2022 - 2024 — McMap. All rights reserved.