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:
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
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.
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.
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:
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.
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.
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