pandoc versión 1.12.3 o superior se requiere y no se encontró (R brillante)


Tengo un problema al generar un informe pdf desde mi aplicación shiny que está alojada en un servidor.

La aplicación funciona bien, pero cuando presiono el botón para descargar el informe, obtengo este error :

 pandoc version 1.12.3 or higher is required and was not found.

El proble es que si escribo pandoc -v obtengo:

 pandoc 1.12.3.3
 Compiled with texmath 0.6.6, highlighting-kate 0.5.6.1.
Syntax highlighting is supported for the following languages:
    actionscript, ada, apache, asn1, asp, awk, bash, bibtex, boo, c, changelog,
    clojure, cmake, coffee, coldfusion, commonlisp, cpp, cs, css, curry, d,
    diff, djangotemplate, doxygen, doxygenlua, dtd, eiffel, email, erlang,
    fortran, fsharp, gnuassembler, go, haskell, haxe, html, ini, java, javadoc,
    javascript, json, jsp, julia, latex, lex, literatecurry, literatehaskell,
    lua, makefile, mandoc, markdown, matlab, maxima, metafont, mips, modelines,
    modula2, modula3, monobasic, nasm, noweb, objectivec, objectivecpp, ocaml,
    octave, pascal, perl, php, pike, postscript, prolog, python, r,
    relaxngcompact, restructuredtext, rhtml, roff, ruby, rust, scala, scheme,
    sci, sed, sgml, sql, sqlmysql, sqlpostgresql, tcl, texinfo, verilog, vhdl,
    xml, xorg, xslt, xul, yacc, yaml
 Default user data directory: /home/daniele/.pandoc
 Copyright (C) 2006-2013 John MacFarlane
 Web:  http://johnmacfarlane.net/pandoc
 This is free software; see the source for copying conditions.  There is no
 warranty, not even for merchantability or fitness for a particular purpose.

Así que supongo que tengo la versión correcta para eso. TexLive también está instalado y la ruta está en $PATH.

Servidor.R

library(shiny)
library(drsmooth)
library(shinyBS)
library(knitr)
library(xtable)
library(rmarkdown)

shinyServer(function(input, output,session) { 

 output$downloadReport <- downloadHandler(
filename = function() {
  paste('report', sep = '.','pdf')
},

content = function(file) {
  src <- normalizePath('report.Rmd')

  # temporarily switch to the temp dir, in case you do not have write
  # permission to the current working directory
  owd <- setwd(tempdir())
  on.exit(setwd(owd))
  file.copy(src, 'report.Rmd')

  library(rmarkdown)
  out <- render('report.Rmd')
  file.rename(out, file)
})

output$tb <- renderUI({
             p(h4("Report")),
            "Dowload a the report of your analysis in a pdf format",
            tags$br(),downloadButton('downloadReport',label="Download report"),
            tags$em("This option will be available soon")
     })
})

* informe.Rmd* no contiene ningún tipo de cálculo, es sólo un mensaje de texto. La generación de pdf funciona bien en mi versión local (macOS), pero no en el servidor.

Gracias de antemano, y estoy aquí para dar otra información si es necesario.

Daniele

Author: Daniele Avancini, 2015-02-10

6 answers

Entra en RStudio y encuentra la variable de entorno del sistema para RSTUDIO_PANDOC

Sys.getenv("RSTUDIO_PANDOC")

Luego pon eso en tu script R antes de llamar al comando render.

Sys.setenv(RSTUDIO_PANDOC="--- insert directory here ---")

Esto funcionó para mí después de haber estado luchando para encontrar cómo rmarkdown encuentra pandoc. Tuve que revisar Github para ver la fuente.

 67
Author: Chris,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2016-05-04 18:53:52

Otra opción para que esto funcione para todos sus scripts de R es definir esta variable globalmente.

En Debian/Ubuntu, agregue la siguiente línea a su .archivo bashrc:

export RSTUDIO_PANDOC=/usr/lib/rstudio/bin/pandoc

En macOS, agregue lo siguiente a su .archivo bash_profile:

export RSTUDIO_PANDOC=/Applications/RStudio.app/Contents/MacOS/pandoc

En Windows (usando Git Bash), agregue lo siguiente a su .archivo bashrc:

export RSTUDIO_PANDOC="/c/Program Files/RStudio/bin/pandoc/"
 10
Author: John Blischak,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2018-04-04 19:39:17

Hey acabo de superar este error. Resolví esto eliminando los 2 archivos pandoc, "pandoc" y "pandoc-citeproc" de la carpeta shiny-server. Luego creé un enlace para cada uno de estos archivos desde la carpeta rstudio-server. Funcionó a las mil maravillas. Este fue un problema para mí cuando estaba tratando de incrustar leaflet en los documentos de rmarkdown de ejecutar un servidor brillante en una máquina linux. Me pareció extraño que cuando lo ejecuté en rstudio en la misma máquina linux funcionó bien, pero no cuando lo ejecuté usando servidor brillante. Por lo tanto, la instalación del servidor shiny de pandoc es antigua/desactualizada. Salud

 1
Author: DTakacs,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2018-05-09 00:26:44

La forma más fácil de resolver este problema es pasar el Sys.setenv(..) comando dentro del comando crontab antes de llamar al RMarkdown:: render. Es necesario separar los dos comandos con un punto y coma:

R -e "Sys.setenv(RSTUDIO_PANDOC='/usr/lib/rstudio-server/bin/pandoc'); rmarkdown::render('File.Rmd', output_file='output.html')"

(Recuerde que la ruta rstudio-server difiere de la versión que no es servidor)

 1
Author: Thomas Goerner,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2018-06-18 15:55:06

Si está intentando ejecutar un script desde la línea de comandos en Windows, solo necesita tener la ruta del directorio en la variable PATH*. También puede crear una variable de usuario separada llamada RSTUDIO_PANDOC y darle a esta variable el directorio*. A continuación, cierre y vuelva a abrir cualquier terminal para actualizar las rutas del sistema.**

*Experimente con un trailing / si tiene problemas. ** No pude señalar una ruta UNC. El // al principio de la ruta de acceso contiene las funciones pandoc del paquete rmarkdown. Si está utilizando una ruta UNC, debe asignarla a una unidad y hacer referencia a la letra de la unidad. Hay maneras de hacer esto dinámicamente. Utilizo un script DOS / batch que encontré a través de Google.

 0
Author: DonkeyKong,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2018-04-20 21:17:03

Para aquellos que no usan RStudio, es posible que solo necesite instalar pandoc en su sistema. Para mí fue

sudo pacman -S pandoc

Y funcionó (Arch Linux).

 0
Author: haff,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2018-06-27 21:53:28