pandoc version 1.12.3 or higher is required and was not found (R shiny)

后端 未结 10 2576
轮回少年
轮回少年 2020-11-29 02:09

I have a problem generating a pdf report from my app shiny which is hosted on a server.

the app works fine but when I press the button to download the report, I get

相关标签:
10条回答
  • 2020-11-29 02:58

    Another option so that this works for all your R scripts is to define this variable globally.

    On Debian/Ubuntu, add the following line to your .bashrc file:

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

    On macOS, add the following to your .bash_profile file:

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

    On Windows (using Git Bash), add the following to your .bashrc file:

    export RSTUDIO_PANDOC="/c/Program Files/RStudio/bin/pandoc/"
    
    0 讨论(0)
  • 2020-11-29 03:02

    Go into RStudio and find the system environment variable for RSTUDIO_PANDOC

    Sys.getenv("RSTUDIO_PANDOC")
    

    Then put that in your R script prior to calling the render command.

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

    This worked for me after I'd been struggling to find how rmarkdown finds pandoc. I had to check github to look at the source.

    0 讨论(0)
  • 2020-11-29 03:03

    If you are trying to run a script from the command line on Windows you just need to have the directory path in the PATH variable*. You can also create a separate User variable named RSTUDIO_PANDOC and give this variable the directory*. Then close and reopen any terminals to refresh the system paths.**

    *Experiment with a trailing / if you are having issues. **I was unable to point to a UNC path. The // at the beginning of the path hosed the rmarkdown package pandoc functions. If you are using a UNC path, you must map it to a drive and reference the drive letter. There are ways to do this dynamically. I use a DOS/batch script which I found via Google.

    0 讨论(0)
  • 2020-11-29 03:05

    I had a similar problem with pandoc on Debian 10 while building a bookdown document. In the Makefile what I did was:

    # use rstudio pandoc
    # this rule sets the PANDOC environment variable from the shell
    build_book1:
        export RSTUDIO_PANDOC="/usr/lib/rstudio/bin/pandoc";\
        Rscript -e 'bookdown::render_book("index.Rmd", "bookdown::gitbook")'
    
    # use rstudio pandoc
    # this rule sets the environment variable from R using multilines
    build_book2:
        Rscript -e "\
        Sys.setenv(RSTUDIO_PANDOC='/usr/lib/rstudio/bin/pandoc');\
        bookdown::render_book('index.Rmd', 'bookdown::gitbook')"
    

    These two rules are equivalent and knit the book successfully.

    I just didn't like the long Rscript command:

    Rscript -e "Sys.setenv(RSTUDIO_PANDOC='/usr/lib/rstudio/bin/pandoc'); bookdown::render_book('index.Rmd', 'bookdown::gitbook')"
    
    0 讨论(0)
提交回复
热议问题