'Failed to compile test.tex. See https://yihui.name/tinytex/r/#debugging for debugging tips. See test.log for more info. Execution halted

output file: test.knit.md

! pdflatex: warning: running with administrator privileges

! Sorry, but C:\Users\jjw11\AppData\Local\Programs\MIKTEX~1.9\miktex\bin\x64\pdflatex.exe did not succeed.

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

!   C:\Users\jjw11\AppData\Local\MiKTeX\2.9\miktex\log\pdflatex.log

Error: Failed to compile test.tex. See https://yihui.name/tinytex/r/#debugging for debugging tips. See test.log for more info.
Execution halted

I got this error message while I was trying to generate pdf file using r markdown.

How can I solve this? I installed tinytex using install.packages("tinytex")

I also tried tinytex::reinstall_tinytex(). But I got this error message

tinytex::reinstall_tinytex()
Error in system2("tlmgr", args, ...) : '"tlmgr"' not found
In addition: Warning message:
In tlmgr(c("info", "--list", "--only-installed", "--data", field,  :
  TeX Live does not seem to be installed. See https://yihui.name/tinytex/.

I installed tinytex using "tinytex::install_tinytex()".

When I installed tinytex using "tinytex::install_tinytex()", I got warning which implies other Latex distribution was already installed.

I tried to generate pdf file after I installed tinytex using "tinytex::install_tinytex()".

But this time I got this error message.

output file: test.knit.md

"C:/PROGRA~1/Pandoc/pandoc" +RTS -K512m -RTS test.utf8.md --to latex --from markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash --output test.tex --template "C:\PROGRA~1\R\R-35~1.3\library\RMARKD~1\rmd\latex\DEFAUL~3.TEX" --highlight-style tango --pdf-engine pdflatex --variable graphics=yes --variable "geometry:margin=1in" --variable "compact-title:yes" 
! Package inputenc Error: Unicode character ??(U+B144)
(inputenc)                not set up for use with LaTeX.

Try other LaTeX engines instead (e.g., xelatex) if you are using pdflatex. For R Markdown users, see https://bookdown.org/yihui/rmarkdown/pdf-document.html
Error: Failed to compile test.tex. See https://yihui.name/tinytex/r/#debugging for debugging tips. See test.log for more info.
In addition: Warning message:
In grepl("==> Fatal error occurred", x[i], fixed = TRUE) :
  input string 1 is invalid in this locale
Execution halted

Do I have to uninstall other Latex distributions?

Then, how can I uninstall other Latex distributions?



Solution 1:[1]

I've solved my problem.

First, I had to install Tex distribution.

I could install Tex distribution by using tinytex::install_tinytex().

Second, I was using CJK(Chinese, Japanese, Korean) characters.

so I had to use different latex engine.

In addition, I had to set mainfont which contains my language(korea) in the YAML header.

I attach YAML header which solved my problem.

title: "Untitled"
author: "jjw"
date: "2019? 10? 17?"
output: 
    pdf_document :
      latex_engine : xelatex
mainfont : NanumGothic

Solution 2:[2]

I was getting the same error after installing MikTex. I then re-started RStudio and it worked for me.

Solution 3:[3]

I also had the same error but it was fixed after I used the following code
tinytex::install_tinytex() it was fixed.

But first I had Miktex installed which gave a total different error so I unstaulted it first then I run the code above and problem solved.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Amit Kohli
Solution 2 cmoshe
Solution 3 Raghda Faris