Tag Archives: linux pandoc rmd

rmd to pdf error: pandoc document conversion failed with error 43

system environment

  • ubuntu 16 </ li>
  • R 3.4.4 </ li>
  • rstudio server – 1.1.463 </ li>
  • rmarkdown 1.6 </ li>
  • knitr 1.21 </ li> </ ul>

    error message

    Error: pandoc document conversion failed with error 43

    error scenario

    is like this error on stackoverflow. An RMD file written in RStudio – Server with Chinese characters can normally generate the corresponding PDF file, but an error will be reported if the command to generate the PDF file is executed from the command line with the following code.

    R -q -e 'rmarkdown::render("myreport.rmd", output_format = "pdf_document")
    

    observed the pandoc command printed by the system when generating PDF in rstudio-server is as follows:

    /usr/lib/rstudio-server/bin/pandoc/pandoc +RTS -K512m -RTS myreport.utf8.md --to latex .....
    

    pandoc command printed when PDF is generated on the command line is as follows:

    /usr/bin/pandoc +RTS -K512m -RTS myreport.utf8.md --to latex...
    

    it can be seen that the pandoc used in the two environments is different, and the version information (pandoc-v) of the two pandoc queries is 1.19 and 1.16 respectively. Therefore, it should be a problem with the PanDoc version.

    error exclusion

    USES the following command to update pandoc in the system. It is found that the pandoc corresponding to the latest version of the system can only be 1.16.

    sudo apt-get install --upgrade pandoc
    

    simply replaces pandoc in rstudio-server with pandoc in the system.

    cd /usr/bin
    sudo mv pandoc pandoc.bak # 备份系统中pandoc的执行文件
    sudo ln -s /usr/lib/rstudio-server/bin/pandoc/pandoc pandoc # 建立软连接,将rstudio-server中的pandoc执行文件链接过来
    

    now that the pandoc command on the system has been replaced with the one in rstudio-server, you can generate PDF reports in the command line environment.