# R markdown does not create a pdf file #1285

Closed
opened this Issue Mar 11, 2018 · 59 comments

Projects
None yet

### bdeepthi commented Mar 11, 2018

 Hi, When I try to knit the vanilla example Rmd file to "pdf" I get the below error. I tried re-installing the packages and restarting the R session several time but it dint help. Output created: test.pdf Error in tools::file_path_as_absolute(output_file) : file 'test.pdf' does not exist Calls: -> In addition: Warning messages: 1: running command '"pdflatex" -halt-on-error -interaction=batchmode "test.tex"' had status 1 2: In readLines(logfile) : incomplete final line found on 'test.log' Execution halted

### condwanaland commented Mar 11, 2018

 I couldn't reproduce this; would you mind adding the minimal structure of Rmd file that fails to knit (i.e., can you include the yaml metadata and any chunks you have)? Could you please also include the output of sessionInfo()

### Zanidean commented Mar 12, 2018

 It looks like this has to do with spaces in the variable file name I was using. These examples take place inside loops. Here is the example of what I was doing that wasn't working:  filename <- paste0("Reports/Documents/", program, ".pdf") rmarkdown::render(input = "Reports/Generator/Batch Template.Rmd", output_format = "pdf_document", output_file = filename)  And this is what made it work.  filename <- paste0("Reports/Documents/", program, ".pdf") %>% gsub(" ", "", .) print(filename) rmarkdown::render(input = "Reports/Generator/Batch Template.Rmd", output_format = "pdf_document", output_file = filename)  And again, only with xelatex and lualatex.

### Zanidean commented Mar 16, 2018

 Did you also run tinytex::install_tinytex()?
Member

### yihui commented Mar 16, 2018

 @Zanidean Please note that rmarkdown 1.9 does not require the tinytex R package. Only the current dev version of rmarkdown requires it. Please also be aware of the fact that the tinytex R package does not require TinyTeX -- the custom LaTeX distribution I made: https://yihui.name/tinytex/r/ You can use any LaTeX distribution with tinytex (the R package). The only problem is that tinytex won't automatically install missing LaTeX packages for you if you don't use TinyTeX (TinyTeX refers to the custom LaTeX distribution; tinytex refers to the R package). @ma1966 I have been desperately looking for someone who can reproduce this issue, since I cannot reproduce it by myself: https://community.rstudio.com/t/6155 So far I have heard both successes and failures, but haven't found a person who can screenshare with me, so I can debug it right on the problematic machine (@Zanidean cannot share due to work restrictions; @bdeepthi has not responded yet). You are the third person who has reported the issue, and I wonder if you are able to share your desktop screen with me.

### ma1966 commented Mar 16, 2018 • edited

 I uninstalled MikTex. Then I installed tinytex::install_tinytex() and got an error:  > tinytex::install_tinytex() trying URL 'http://mirror.ctan.org/systems/texlive/tlnet/install-tl.zip' Content type 'application/zip' length 19439353 bytes (18.5 MB) downloaded 7.9 MB trying URL 'https://github.com/yihui/tinytex/raw/master/tools/pkgs-custom.txt' Content type 'text/plain; charset=utf-8' length 267 bytes downloaded 267 bytes trying URL 'https://github.com/yihui/tinytex/raw/master/tools/texlive.profile' Content type 'text/plain; charset=utf-8' length 295 bytes downloaded 295 bytes Error in setwd(dir) : character argument expected In addition: Warning messages: 1: In download.file("http://mirror.ctan.org/systems/texlive/tlnet/install-tl.zip", : downloaded length 8257536 != reported length 19439353 2: In unzip("install-tl.zip") : error 1 in extracting from zip file Restart your R session and check if tinytex:::is_tinytex() is TRUE.  Then I restart rstudio and tinytex:::is_tinytex() was FALSE. Yes I can share my screen. Are you available today?
Member

### yihui commented Mar 16, 2018 • edited

 @ma1966 Downloading the installer was not complete for some reason. You may try tinytex::install_tinytex() again, but please do me a favor not to do it before we chat, so that you can still reproduce the issue when I'm ready to investigate the issue on your computer. Thanks! Edit: Oh I just saw you had uninstalled MiKTeX. Well, then please try tinytex::install_tinytex() again, and see if a different LaTeX distribution can fix your issue.

### ma1966 commented Mar 16, 2018 • edited

 I uninstalled MikTex as recommended in your post and thought install_tinytex would install TeX live. I will wait for the chat. Thanks again.

### thiagocmattar commented Mar 17, 2018 • edited

 Hello everyone, I got this issue too. I'm using MikTeX with rmarkdown. This issue is caused by the lack of some packages required to compile the pdf and rmarkdown apparently is not able to require the downloads. So I opened a sweve file and wrote the same document and when I compiled, MikTeX asked to download some packages. After that rmarkdown is working fine.

### jmschallock commented Mar 17, 2018

 Hi everyone, just wanted to chime in to say I was struggling with this issue today too, and going back to rmarkdown 1.8 seems to have fixed it for me.
Member

### yihui commented Mar 17, 2018

 @thiagocmattar Interesting. I wonder if there is a chance that you still remember which missing packages MiKTeX installed? @jmschallock Do you have a minimal reproducible example? Any spaces in your filenames?

### JasonCEC commented Mar 17, 2018 • edited

 I am having this issue as well, MikTeX with rmarkdown (version 1.9) on Windows 8.1. If I output a .tex file and compile it in MikTeX it works fine, but fails with render(..) My packages are: \usepackage{multicol} \usepackage{fancyhdr} Edit: going back to rmarkdown version 1.8 did not fix the problem for me

### JasonCEC commented Mar 17, 2018

 Edit 2: I got the PDF rendering again by uninstalling MikTex 2.9.? and updating to the most recent version; now with (rmarkdown 1.8 still installed) I can user render(...) and it all works.

### jmschallock commented Mar 18, 2018

 @yihui I'm afraid I wasn't very diligent with documenting what I did, but I updated R and RStudio to the latest versions and reverted to rmarkdown 1.8. No spaces in any of my filenames. (Also just want to say thank you for all your work building and supporting such awesome packages! You're kind of my hero :)

Closed

Member

### yihui commented Mar 19, 2018 • edited

Hi everyone, I think I have finally figured out the root causes (one of which was rstudio/rstudio#2446) of the issues reported in this thread, and below are two possible solutions (with the latest version of rmarkdown on CRAN, i.e. v1.9):

## If you have to use MiKTeX

You can install the devel version of the R package tinytex:

devtools::install_github('yihui/tinytex')

If you haven't installed MiKTeX, remember to check the option Yes in Install missing packages when installing it:

If you have already installed MiKTeX, go to the Start menu, find the menu "MiKTeX Console", and choose the option Always install missing packages on-the-fly:

## If you don't have to use MiKTeX

Things will be a little easier. Uninstall MiKTeX if you have installed it (or temporarily rename its installation folder if you don't want to get rid of it completely), then in R:

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

This will install TinyTeX (a custom version of TeX Live), which can also build LaTeX documents to PDF on Windows. For more info, see https://yihui.name/tinytex/. Restart RStudio/R when the installation is done (it may take 3-5 minutes).

Please let me know if you still have trouble. Thanks!

Closed

Closed

Member

### yihui commented Mar 26, 2018

 Hi @bdeepthi @Zanidean @JasonCEC @jmschallock @thiagocmattar @ma1966, can any of you confirm if the CRAN version of rmarkdown work with the dev version of tinytex when rendering PDF? install.packages('rmarkdown') devtools::install_github('yihui/tinytex') Since I haven't heard back from any of you, I feel nervous about making a new release of tinytex to CRAN. R package authors are allowed to make at most six releases of a package in six months, and I have already used four chances since last December, so I have to be very cautious now. Thanks!

### Zanidean commented Mar 26, 2018

 @yihui Working for me.

### boshek commented Mar 28, 2018

 @yihui For what it's worth it works for me as well. Session Info Session info ---------------------------------------------------------------------------------------------------------------------------------------------------- setting value version R version 3.4.4 (2018-03-15) system x86_64, mingw32 ui RStudio (1.1.442) language (EN) collate English_Canada.1252 tz America/Los_Angeles date 2018-03-28 Packages -------------------------------------------------------------------------------------------------------------------------------------------------------- package * version date source backports 1.1.2 2017-12-13 CRAN (R 3.4.3) base * 3.4.4 2018-03-15 local compiler 3.4.4 2018-03-15 local datasets * 3.4.4 2018-03-15 local devtools * 1.13.5 2018-02-18 CRAN (R 3.4.3) digest 0.6.15 2018-01-28 CRAN (R 3.4.3) evaluate 0.10.1 2017-06-24 CRAN (R 3.4.3) graphics * 3.4.4 2018-03-15 local grDevices * 3.4.4 2018-03-15 local htmltools 0.3.6 2017-04-28 CRAN (R 3.4.3) knitr 1.20 2018-02-20 CRAN (R 3.4.3) lobstr * 0.0.0.9000 2018-03-14 Github (r-lib/lobstr@75254f1) magrittr 1.5 2014-11-22 CRAN (R 3.4.3) memoise 1.1.0 2017-04-21 CRAN (R 3.4.0) methods * 3.4.4 2018-03-15 local R6 2.2.2 2017-06-17 CRAN (R 3.4.3) Rcpp 0.12.16 2018-03-13 CRAN (R 3.4.4) rlang 0.2.0 2018-02-20 CRAN (R 3.4.3) rmarkdown * 1.9 2018-03-01 CRAN (R 3.4.4) rprojroot 1.3-2 2018-01-03 CRAN (R 3.4.3) stats * 3.4.4 2018-03-15 local stringi 1.1.7 2018-03-12 CRAN (R 3.4.4) stringr 1.3.0 2018-02-19 CRAN (R 3.4.3) testthat * 2.0.0 2017-12-13 CRAN (R 3.4.3) tinytex * 0.4.2 2018-03-28 Github (yihui/tinytex@c7d62e1) tools 3.4.4 2018-03-15 local usethis * 1.3.0 2018-02-24 CRAN (R 3.4.3) utils * 3.4.4 2018-03-15 local withr 2.1.2 2018-03-15 CRAN (R 3.4.4) yaml 2.1.18 2018-03-08 CRAN (R 3.4.3) 03-08 CRAN (R 3.4.3) 
Member

### yihui commented Mar 28, 2018

 Excellent! Thanks @Zanidean and @boshek!

Closed

Member

### yihui commented Apr 16, 2018

 FYI I have submitted the new version of tinytex (0.5) to CRAN: https://cran.r-project.org/package=tinytex Hopefully in about two days, update.packages() will solve all problems.

### mbedward commented May 25, 2018

 Joining in late but just in case this is helpful to anyone. On my windows 10 system tinytex::install was failing some way into the process. It turned out to be caused by wget not being installed. After installing it everything worked. Perhaps the batch file could check for wget and issue a message if not found? My thanks and respect for all the fabulous work.
Member

### yihui commented May 25, 2018

 @bdeepthi Please see yihui/tinytex#49 (the short answer is you will have to wait for at least two days before you can tinytex::install_tinytex()).

Closed

### ga122493 commented Jun 13, 2018 • edited

 @mbedward Sorry this is a silly question, how did you install wget -- was this for R/R Studio? @yihui The fix works for regular pdf knitting. However, for pdf beamer, I uninstalled MikTex and installed tinytex on my window machine -- the problem is still there... The error is Output created: Lecture3_slides_060418.pdf Error in tools::file_path_as_absolute(output_file) : file 'Lecture3_slides_060418.pdf' does not exist Calls: < Anonymous > -> < Anonymous > Execution halted Looking through the log file and this has an error message, not sure if it helps... (c:/Users/tyankama/AppData/Roaming/TinyTeX/texmf-dist/tex/generic/oberdiek/infw arerr.sty Package: infwarerr 2016/05/16 v1.4 Providing info/warning/error messages (HO)) I also experience this on a Mac computer, which I already posted an issue here #1360 Any suggestions? Thank you!!

### mbedward commented Jun 13, 2018

 @ga122493 I installed wget on my system (Windows 10), using the version from gnuwin32 on sourceforge. But I think yihui/tinytex#49 suggests that the need for wget was due to a problem in the tinytex install script and it should no longer be required.
Member

### yihui commented Jun 13, 2018

 @mbedward You are right. Just forget about wget. It is irrelevant now. @ga122493 The message you posted from the LaTeX log file was not an error message. Error messages in LaTeX typically start with !. I have seen your #1360. Please hold on, and give me a little more time to breathe :) To all: I'm going to lock this issue, since the original problem has been solved. The solution was install.packages('tinytex')`. If anyone runs into new issues, please file new issues separately. Thanks!