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?
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).
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/
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.
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")
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
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
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.
I know this is an old question, but as vivek mentioned, restarting the server worked for me:
sudo systemctl restart shiny-server
Related
I have had various R Shiny applications running successfully (some for over a year) on a Windows PC serving a local intranet network.
In the last couple of weeks, the applications started to fail loading plots with the error:
unable to start png() device.
Restarting the application would fix the problem, but only for a few hours when it would error again.
At the time I had not changed anything in R, although since the isuue started I have updated everything hoping it would fix the problem. There was no change after the updates.
When I load an app that is freshly restarted there are no warnings. When there are errors, the console prints the following:
unable to open file 'C:\Users\jgerla03\AppData\Local\Temp\Rtmp4QtNQ2\file91819b61552' for writing
Warning in dev_fun(file = tempfile(), width = width %||% 640, height = height %||% :
opening device failed
Warning: Error in dev_fun: unable to start png() device
107: dev_fun
106: gg2list
105: ggplotly.ggplot
102: plotly_build.gg
98: getFromNamespace("prepareWidget", "plotly")
97: shinyRenderWidget
96: func
83: renderFunc
82: output$fmc_summary_plot
1: shiny::runApp
Warning in normalizePath(path.expand(path), winslash, mustWork) :
path[1]="C:\Users\jgerla03\AppData\Local\Temp\Rtmp4QtNQ2": The system cannot find the file specified
The shiny apps are run from an admin account with highest privileges (run from Windows 10 Task Scheduler or commandline). The appdata temp folder specified in the error message gives all users permission to read/write/everything, but the toggle saying "read only" is on everytime I open the "properties" window for the folder (despite me unclicking it and applying each time).
I am so confused because everything works perfectly for the first few hours after a restart which makes this issue more difficult to test.
This seems similar to Error: unable to start png() device in R Shiny Dashboard , which never received a response. I hope the extra detail I provided will help someone to suggest a solution.
I have seen similar behaviour using a ubuntu shiny server and it was traced back to running out of system resources (disk space in my case) which ment that temporary files could not be created.
Your error message ...
"unable to open file 'C:\Users\jgerla03\AppData\Local\Temp\Rtmp4QtNQ2\file91819b61552'"
looks similar to what I experienced. I'm not familiar with Windows OS but would suggest you look into the possibility that you are running out of disk or memory space..
Peter
I am running Red Hat Enterprise Linux (RHEL) 8.5 with Linux kernel 4.18 and Gnome 3.32.2. In this system, I've got R 4.1.2 compiled with the tool asdf with shared libraries enabled. On top of that, I installed RStudio 2021.09.01-372 from an RPM from the official RStudio website.
When I start Rstudio, the first line of output after the usual R startup is an error:
Error in tools::startDynamicHelp() : internet routines cannot be loaded
I am unable to figure out what's causing this error, and with it I can't run things like refresh CRAN or update packages. But if I start a pure R session from the terminal (instead of Rstudio) this error does not occur.
Some things I tried:
Install the krb5 and libssh2 packages on my host system: Didn't help.
Starting a "pure" R session (both with and without the --vanilla argument) from the Terminal tab within Rstudio also gives this error. If I try to run update.packages() from this session, it pops up a window to select a CRAN mirror then fails with the following:
Warning: failed to download mirrors file (internet routines cannot be loaded); using local file '/home/[my username]/.asdf/installs/R/4.1.2/lib64/R/doc/CRAN_mirrors.csv'
Warning: unable to access index for repository https://cloud.r-project.org/src/contrib:
internet routines cannot be loaded
Warning message:
In download.file(url, destfile = f, quiet = TRUE) :
unable to load shared object '/home/penyuan/.asdf/installs/R/4.1.2/lib64/R/modules//internet.so':
/lib64/libssh.so.4: undefined symbol: EVP_KDF_ctrl, version OPENSSL_1_1_1b
But like I said, the strange thing is if I start an R session outside of Rstudio, these errors don't happen.
Within RStudio, the only workaround I can find is to run this command upon startup (suggested in this thread):
options(download.file.method="wget")
Once this is done, everything else seems to work, such as package updates.
However, I don't want to manually do this every time I start RStudio. So I tried to put it into ~/.Rprofile including a test print() as follows:
print("This is `~/.Rprofile`")
options(download.file.method="wget")
When I open RStudio, I can see the output from the print() call, but the options() command is not run because the original error shows up again. I still have to manually enter options(download.file.method="wget") every time.
I also tried to fold everything into a .First function in ~/.Rprofile as follows:
.First <- function() {
options(download.file.method="wget")
print("This is the `.First` function in `~/.Rprofile`")
}
Unfortunately, same result as before: print()'s output is seen, but options() is not run.
I also made sure that my ~/.Rprofile includes a trailing newline as discussed here. But this didn't help.
The above are the steps I've tried so far.
Why does this error only occur when running RStudio or a terminal within Rstudio? Why doesn't it happen if I start R from a terminal outside of Rstudio?
Is there a way to solve the problem so that the error doesn't happen in the first place? If it can't be solved, how do I set up my ~/.Rprofile so that options(download.file.method="wget") will be run?
Thank you.
I have to use RStudio to knit a report in PDF but when I try to knit the document with the packages required in a chunk in Rmarkdown it shows me this error:
tlmgr search --file --global '/multirow.sty'
tlmgr: Remote repository is newer than local (2018 < 2019)
Cross release updates are only supported with
update-tlmgr-latest(.sh/.exe) --update
Please see https://tug.org/texlive/upgrade.html for details.
! LaTeX Error: File `multirow.sty' not found.
! Emergency stop.
<read *>
Errore: Failed to compile questionario_sulla_responsabilita_222222.tex. See https://yihui.name/tinytex/r/#debugging for debugging tips. See questionario_sulla_responsabilita_222222.log for more info.
Inoltre: Warning message:
In system2("tlmgr", args, ...) :
running command ''tlmgr' search --file --global '/multirow.sty'' had status 1
Execution interrupted
how can I fix this? I am using a MacBook Pro
I tried to updated everything I can and I've tried to install everything from the beginning but it jeeps showing me the same error message
To wrap the comments to the question up and following the solution at Yihui Xie's page - see also here for a discussion.
In short ...
tinytex::reinstall_tinytex()
... should do the trick.
Explanation: It seems that {tinytex}/Texlive is using a rolling package repository that moves to a new version each year while the local installment does not. The reinstallation does move the local installment forward.
An alternative solution: There seems to be an alternative solution that involves making the TexLive package repo un-rolling - i.e. using a fixed version - which might help: link
I am currently moving a (localhost) shiny App from a windows 32-bit to windows 64-bit . Google didn't managed to answer my problem :( so I'm asking the community !
This App worked fine on 32 bits, I had to re-install R, all Packages, Java on the 64-bit machine (each in the 64-bit mode). My app has the following file architecture :
a gloabl.R file where I load libraries
a server.R
List item
a ui.R
another file which format data to be sent d3/nvd3
a JS file to display a linechart.
the error I have is the following :
Warning in file(con, "rb") : file("") only supports open = "w+" and
open = "w+b": using the former Warning: Error in readChar: invalid
'nchars' argument Stack trace (innermost first):
1: runApp Error : invalid 'nchars' argument
When I'm running code without shiny, all works fine, all is precessed and results are good.
Does anyone has ever been facing to this ?
If you need anything just ask I will be more specific. I am not giving you the code, he is a little tricky and is in multiple files... And I think it is specific to my new environement.
Reinstalling solely the shiny-package fixed the problem for me. I am using R-studio, and did the operation through the Packages window (deleted and reinstalled).
This question is a corollary of my attempts to get some experience with creating reproducible reports from R Markdown documents via knitr and rmarkdown R packages. While it seems that .Rmd => HTML conversion is automated from within RStudio (Knit HTML button), my attempt to do the same outside of RStudio (Rscript -e 'library(rmarkdown); render("knitr-example-slides-1.Rmd")') failed due to, according to the message, lack of pandoc on my system. This is most likely false, since RStudio somehow managed to perform the conversion. Therefore, it is most likely an access and/or path issue.
Without knowledge of where RStudio maintains pandoc and details about the access, I have decided to install pandoc myself. Unfortunately, sudo apt-get install pandoc has not been very helpful, due to the fact that current version of pandoc in Ubuntu's trusty repository (14.04LTS) is 1.12.2.1. According to rmarkdown's message, version 1.12.3 or higher is required. "Not a big deal", I have thought, and followed instructions on installing pandoc in case of too old version in repository (http://johnmacfarlane.net/pandoc/installing.html). That requires installing the Haskell platform, which is pretty big and which output is rather verbose. After some time, I finally has been greeted with the following failure message:
[ 6 of 57] Compiling Text.Pandoc.Readers.TeXMath ( src/Text/Pandoc/Readers/TeXMath.hs, dist/build/Text/Pandoc/Readers/TeXMath.o )
src/Text/Pandoc/Readers/TeXMath.hs:30:38:
Ambiguous occurrence `readTeXMath'
It could refer to either `Text.Pandoc.Readers.TeXMath.readTeXMath',
defined at src/Text/Pandoc/Readers/TeXMath.hs:56:1
or `Text.TeXMath.readTeXMath',
imported from `Text.TeXMath' at src/Text/Pandoc/Readers/TeXMath.hs:33:1-19
(and originally defined in `Text.TeXMath.Parser')
Failed to install pandoc-1.12.4.2
cabal: Error: some packages failed to install:
pandoc-1.12.4.2 failed during the building phase. The exception was:
ExitFailure 1
pandoc-citeproc-0.3.1 depends on pandoc-1.12.4.2 which failed to install.
Firstly, I'm not sure how to fix it. Secondly, I very much suspect that there should be an easier way to enjoy generating reproducible reports with rmarkdown and pandoc than this. Your advice will be appreciated!
UPDATE (see comments):
Rscript -e 'library(rmarkdown); render("knitr-example-slides-1.Rmd")'
processing file: knitr-example-slides-1.Rmd
|....... | 11%
ordinary text without R code
|.............. | 22%
label: setup (with options)
List of 1
$ include: logi FALSE
Quitting from lines 6-8 (knitr-example-slides-1.Rmd)
Error in eval(expr, envir, enclos) : object 'opts_chunk' not found
Calls: render ... handle -> withCallingHandlers -> withVisible -> eval -> eval
Execution halted
Basically, #daroczig answered this question in his comment above, so I will repeat it here, plus will add an answer to the relevant minor question on the issue, appeared after the main question's issue fix.
1) "A binary compiled version of Pandoc is already shipped with RStudio, so you can simply create a symlink, so that you could easily use that outside of the RStudio eco-system: https://github.com/rstudio/rmarkdown/blob/master/PANDOC.md#newer-systems-debianubuntufedora";
2) I have fixed the error, experienced after applying the advice above (see my comment), by calling opts_chunk() using explicit package reference: knitr::opts_chunk(), following guidelines here: http://rmarkdown.rstudio.com/authoring_migrating_from_v1.html (thanks to #Yihui for pointing me to this document in a different question: Transitioning research project to knitr-based setup).