I am trying to use knitr in RStudio to make a pdf (using pdflatex/MiKTeX). I'm on a Windows 10 machine. This was working fine until I updated R, RStudio, and MikTeX this month (Feb 2021). I'm getting an error that says,
"Running pdflatex.exe on testdoc.tex...failed Error running C:/Users/myusername/AppData/Local/Programs/MiKTeX/miktex/bin/x64/pdflatex.exe (exit code -1073740791)"
OR C:/PROGRA~1/MiKTeX/miktex/bin/x64/pdflatex.exe
My file is named testdoc.Rnw and contains:
\documentclass{article}
\begin{document}
some text
\end{document}
- I have already uninstalled and reinstalled MiKTeX, R, and Rstudio trying both user and administrator. (All of my versions are current as of 2/19/2021)
- This problem occurs whether I use user or administrator mode.
- The path given in the error is the correct one.
- The paths when I type
Sys.which("pdflatex")
are correct. - No Log file is created. It just gets to the part where it tries to run pdflatex and gives the error.
- I can build and view the .tex file that is generated using TeX Studio.
- My MiKTeX console is updated.
- I've selected "knitr" in my options and tried checking and unchecking most of the checkboxes. Closing and opening and restarting.
I would prefer not to switch to TinyTeX. I have tried every suggestion I could find in Rstudio and stack overflow posts. I have looked at log files. I notice I'm not the only one with this problem, but everyone else seems to have a different error number. Please help.
Here is the output from sessionInfo()
:
R version 4.0.4 (2021-02-15)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 16299)
Matrix products: default
locale:
[1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252
[3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C
[5] LC_TIME=English_United States.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
loaded via a namespace (and not attached):
[1] compiler_4.0.4 tools_4.0.4
For my environment variables for "path" (and I have tried changing them at the system level) I have tried C:\PROGRA~1\MiKTeX\miktex\bin\x64\
and C:\Users\myusername\AppData\Local\Programs\MiKTeX\miktex\bin\x64\
. I also tried running as both administrator and as my user. It seems to make no difference.
I did just notice based on a comment that Sys.which("pdftex")
and Sys.which("pdflatex")
both return the same thing and I don't know if it matters.
I can create a pdf using the tex file either in texstudio or in the command line. Here is the output from running it in the command line:
This is pdfTeX, Version 3.141592653-2.6-1.40.22 (MiKTeX 21.2)
entering extended mode
(testdoc.tex
LaTeX2e <2020-10-01> patch level 4
L3 programming layer <2021-02-18> xparse <2020-03-03>
(C:\Program Files\MiKTeX\tex/latex/base\article.cls
Document Class: article 2020/04/10 v1.4m Standard LaTeX document class
(C:\Program Files\MiKTeX\tex/latex/base\size10.clo))
(C:\Program Files\MiKTeX\tex/latex/graphics\graphicx.sty
(C:\Program Files\MiKTeX\tex/latex/graphics\keyval.sty)
(C:\Program Files\MiKTeX\tex/latex/graphics\graphics.sty
(C:\Program Files\MiKTeX\tex/latex/graphics\trig.sty)
(C:\Program Files\MiKTeX\tex/latex/graphics-cfg\graphics.cfg)
(C:\Program Files\MiKTeX\tex/latex/graphics-def\pdftex.def)))
(C:\Program Files\MiKTeX\tex/latex/graphics\color.sty
(C:\Program Files\MiKTeX\tex/latex/graphics-cfg\color.cfg))
(C:\Users\myusername\AppData\Roaming\MiKTeX\tex/latex/framed\framed.sty)
(C:\Program Files\MiKTeX\tex/latex/base\alltt.sty)
(C:\Users\myusername\AppData\Roaming\MiKTeX\tex/latex/upquote\upquote.sty)
(C:\Program Files\MiKTeX\tex/latex/l3backend\l3backend-pdftex.def)
No file testdoc.aux.
(C:\Program Files\MiKTeX\tex/context/base/mkii\supp-pdf.mkii
[Loading MPS to PDF converter (version 2006.09.02).]
) (C:\Program Files\MiKTeX\tex/latex/epstopdf-pkg\epstopdf-base.sty) [1{C:/User
s/myusername/AppData/Local/MiKTeX/pdftex/config/pdftex.map}] (testdoc.aux) )<C:/Pro
gram Files/MiKTeX/fonts/type1/public/amsfonts/cm/cmr10.pfb>
Output written on testdoc.pdf (1 page, 12954 bytes).
Transcript written on testdoc.log.