6

After I updated R to version 3.5.0, I couldn't start my MikTex from Rstudio,

---
output:
  pdf_document:
    latex_engine: xelatex 
    includes:
      in_header: header.tex
    keep_tex: yes
---

Above is the code I typed ahead of my Rmd, and after knitring,

Sorry, but D:\miktex\miktex\bin\x64\xelatex.exe did not succeed.

The log file hopefully contains the information to get MiKTeX going again:

  C:/Users/DELL/AppData/Local/MiKTeX/2.9/miktex/log/xelatex.log

Information showed in xelatex.log:

2018-04-29 10:06:17,482+0800 FATAL xelatex - Info: 
2018-04-29 10:06:17,482+0800 FATAL xelatex - Source: Libraries\MiKTeX\UI\Qt\mikuiqt.cpp
2018-04-29 10:06:17,482+0800 FATAL xelatex - Line: 45
2018-04-29 10:06:17,482+0800 INFO  xelatex - finishing with exit code 1
2018-04-29 10:06:17,626+0800 INFO  xelatex - starting with command line: D:\miktex\miktex\bin\x64\xelatex.exe -halt-on-error -interaction=batchmode 1.tex
2018-04-29 10:06:17,631+0800 INFO  xelatex - allowing known shell commands
2018-04-29 10:06:17,632+0800 INFO  xelatex - enabling input (output) from (to) processes
2018-04-29 10:06:17,812+0800 FATAL xelatex - GUI framework cannot be initialized.

And after I tried:

Sys.which("xelatex")

                                    xelatex 
"D:\\miktex\\miktex\\bin\\x64\\xelatex.exe"

Sys.setenv("PATH" = "D:\miktex\miktex\bin\x64\xelatex.exe" )

then knitr again:

Warning messages:

1: In system2(..., stdout = FALSE, stderr = FALSE) : '"xelatex"' not found
2: In system2(...) : '"xelatex"' not found

No TeX installation detected (TeX is required to create PDF output). You should install a recommended TeX distribution for your platform:

  Windows: MiKTeX (Complete) - http://miktex.org/2.9/setup
  (NOTE: Be sure to download the Complete rather than Basic installation)

Could anyone help? Thanks.

Deku
  • 81
  • 1
  • 3
  • 5
    Do not adjust `PATH` like that (the value you passed is invalid -- should be a dir instead of file path). `GUI framework cannot be initialized` indicates that you should try this: https://yihui.name/en/2018/03/miktex-auto-install/ Or [better, use TinyTeX](https://yihui.name/tinytex/pain/) instead. Anyway, it is odd that it fails after you upgrade R; the version of R should be irrelevant here. – Yihui Xie Apr 29 '18 at 14:27
  • 1
    But what did you do? (I mentioned two ways) I recommend you to post an answer to your own question. – Yihui Xie Apr 29 '18 at 18:13

1 Answers1

4

as mentioned, you can change the default setting and let MiKTeX install the missing LaTeX packages without asking:

From the MiKTeX Console → settings → "Always install missing packages on-the-fly".

ah bon
  • 9,293
  • 12
  • 65
  • 148