Knitr wont compile PDF: “Error in tools::file_path_as_absolute(output_file)”

前端 未结 5 383
粉色の甜心
粉色の甜心 2020-12-01 08:15

I have created a report in markdown and use the function render() to compile the code into a PDF. It worked fine a month ago, but when I run the code now, it gi

相关标签:
5条回答
  • 2020-12-01 08:16

    A better solution appears to be to use tinytex.

    install.packages('tinytex')
    tinytex::install_tinytex()
    

    If you have to use MikTex and have it installed already, open the MikTex console and change the missing package setting to:

    Always install missing packages on the fly
    

    If you have not installed MikTex yet then on installation make sure to choose:

    Install missing packages: Yes
    

    When I originally installed I chose Ask me first and it would fail. I have tried both changing the settings of MikTex, as well as uninstalled it and just settled for tinytex which was a bit more lightweight for my needs.

    The original thread with solution near the bottom: https://github.com/rstudio/rmarkdown/issues/1285

    0 讨论(0)
  • 2020-12-01 08:27

    I had similar problem. After searching in the internet, I found a solution in community r studio

    It seems the bug is related with 1.9 version of rmarkdown, so the solution is to return to 1.8 version

    install.packages("devtools")
    library(devtools)
    install_version("rmarkdown",version=1.8)
    

    After reinstalling, when you try to knit again, probably you will be asked to install some package from Miktex. If you have any problem, check for a proper mirror. Hope this helps.

    0 讨论(0)
  • 2020-12-01 08:30

    In the meanwhile the issue seems to be fixed in the development version 1.10.11:

    devtools::install_github('rstudio/rmarkdown')
    
    0 讨论(0)
  • 2020-12-01 08:30

    Just a comment to the output question, as I got stuck with this, too: the outfile must be the absolute path. I think dir.exists() looks in the local working directory. Using ".\\" in front helped in my case. In yours it would be using paste0(".\\",outfile,".pdf").

    0 讨论(0)
  • 2020-12-01 08:34

    If using MikTex, you probably missing some packages (basic Miktex packages are installed). Just compile your tex file to find out missing packages (compile errors) and install them. Then knit your rmd document and it should work.

    0 讨论(0)
提交回复
热议问题