Failed to run c:/..../pdflatex.exe

I've been struggling with this for 8 weeks now and still no resolution. I've been through many of the proposed solutions to rmarkdown - compile pdf with no resolution including reinstalling R, RStudio, rmarkdown, tinytex, tinytex:::install_prebuilt(), ... . I've used rmarkdown for creating pdfs for 4 years without issue (except those of my own making) and suddenly in November, I started getting the messages for the two-authors.rmd example below the errors:

processing file: two-authors.Rmd
output file: two-authors.knit.md

Error: Failed to compile two-authors.tex. See https://yihui.org/tinytex/r/#debugging for debugging tips.
In addition: Warning messages:
1: In system2(..., stdout = if (use_file_stdout()) f1 else FALSE, stderr = f2) :
'CreateProcess' failed to run 'C:\Users\David Stevens\AppData\Roaming\TinyTeX\bin\win32\pdflatex.exe -halt-on-error -interaction=batchmode "two-authors.tex"'
2: In system2("tlmgr", args, ...) :
'CreateProcess' failed to run 'C:\Users\David Stevens\AppData\Roaming\TinyTeX\bin\win32\tlmgr.bat update --all --self'
Execution halted

Two-authors.rmd

title: "Two authors"
output: pdf_document
author:

  • John Doe
  • Jane Doe

The default LaTeX template should work with multiple authors: https://github.com/rstudio/rmarkdown/issues/1716

Sys.which('pdflatex') gives the right path. I don't know where to turn to fix this. Thankfully, I can use RStudio Cloud and all is well but that isn't always available to me. I'd really like to get back to where rmarkdown (and bookdown) can compile to pdf.

My system - Windows 10, R 3.6.2, RStudio 1.2.5033, latest rmarkdown/tinytex and miktex 2.9.

From the log message, it seems Rmarkdown is not using MikTex but TinyTex distribution.
C:\Users\David Stevens\AppData\Roaming\TinyTeX\bin\win32\pdflatex.exe

Do you have both ?

You said you used tinytex:::install_prebuilt() so you installed TinyTex package distribution ?

You can try reinstalling tinytex::reinstall_tinytex() or uninstalling tinytex::uninstall_tinytex()

Not sure how it behave with both MikTex and TinyTex.

What is the right path for you ?

It's the path the the tinytex version

Sys.which('pdflatex.exe')
pdflatex.exe
"C:\Users\David Stevens\AppData\Roaming\TinyTeX\bin\win32\pdflatex.exe"

It's interesting that the pdflatex.exe in tinytex is 1536 byes while the same in Miktex is 1.8 mb

C:>dir/s pdflatex.exe
Volume in drive C is OS
Volume Serial Number is 181E-E415

Directory of C:\Users\David Stevens\AppData\Local\Programs\MiKTeX 2.9\miktex\bin\x64

11/11/2019 02:14 PM 1,186,304 pdflatex.exe
1 File(s) 1,186,304 bytes

Directory of C:\Users\David Stevens\AppData\Roaming\TinyTeX\bin\win32

01/10/2020 02:36 PM 1,536 pdflatex.exe
1 File(s) 1,536 bytes

DId you try activate more verbose as advice in the debugging tips ?

Is there some new message ?

I suspect there is something non R related going on in your environmment.

Those error message are from a call from system2 on your computer, while trying to execute some executable file. If you search 'CreateProcess' failed to run on google, you'll found some stuff regarging Windows and CMD.

Wild guess for some post I found online: can you check the COMSPEC environment variable ?
echo %COMSPEC% in CMD window terminal or another way. Should point to cmd.exe.

Also, you can try going into CreateProcess' failed to run 'C:\Users\David Stevens\AppData\Roaming\TinyTeX\bin\win32 and see if you can exectute the file yourself from command line or double click.

Hope it helps

Thanks cderv, I'll give these a try and report back.

I looked in the 'C:\Users\David Stevens\AppData\Roaming\TinyTeX\bin\win32 folder and there IS NO CreateProcess.exe. This is surprising because I've un/reinstalled tinytex several times in the past week.I take it this is installed when tinytex is installed. Where would I get a replacement?

Using the verbose option didn't change the error message. The COMPSEC variable points correctly to the existing cmd.exe.

The CreateProcess is a windows stuff. This is not from TinyTex. I guess this is something used when running windows runs other programs through command line.

In you current error messages you see the two executable that windows try to run:

  • C:\Users\David Stevens\AppData\Roaming\TinyTeX\bin\win32\pdflatex.exe
  • C:\Users\David Stevens\AppData\Roaming\TinyTeX\bin\win32\tlmgr.bat

The error is from windows that do not manage to run the command lines that R asked to run using system2. I don't know why. You could look into the windows CreateProcess error on google or SO in order to understand what this is.

Antivirus

Do you have a 3rd party antivirus application running on your system? Searching around looks like these can sometime result in that error.

Privileges

Another thing to try might be run Rstudio as administrator. That probably elevates the child processes as well. If it works, it tells you that it's a permissions issue. Although running as administrator is a rather heavy handed work around, it may be useful to identify the problem.

1 Like

Thanks for your input. I have tried running as Administrator and I get the same results. In task manager, I don't see any extra antivirus. I haven't knowingly installed any such software but you never know. I'll keep digging on that.
Best
David

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.