R Markdown unable to knit to PDF - R 4.0.2 on Windows 10

Hi!

I spent many hours trying to knit a standard R Mardown to PDF and searching for a solution that could work before I decided to post in here, but unfortunatelly I didn't find any. I hope someone could borrow me some ideas and/or experiences in order to solve this issue.

This is the output:

processing file: Teste3.Rmd
|.......... | 14%
ordinary text without R code

|.................... | 29%
label: setup (with options)
List of 1
$ include: logi FALSE

|.............................. | 43%
ordinary text without R code

|........................................ | 57%
label: cars
|.................................................. | 71%
ordinary text without R code

|............................................................ | 86%
label: pressure (with options)
List of 1
$ echo: logi FALSE

|......................................................................| 100%
ordinary text without R code

"C:/Program Files/RStudio/bin/pandoc/pandoc" +RTS -K512m -RTS Teste3.utf8.md --to latex --from markdown+autolink_bare_uris+tex_math_single_backslash --output Teste3.tex --self-contained --highlight-style tango --pdf-engine pdflatex --variable graphics --lua-filter "C:/Users/Glauco Gavioli/Documents/R/win-library/4.0/rmarkdown/rmd/lua/pagebreak.lua" --lua-filter "C:/Users/Glauco Gavioli/Documents/R/win-library/4.0/rmarkdown/rmd/lua/latex-div.lua" --variable "geometry:margin=1in"
output file: Teste3.knit.md

Error in system2("tlmgr", args, ...) :
'CreateProcess' failed to run 'C:\Users\Glauco Gavioli\AppData\Roaming\TinyTeX\bin\win32\tlmgr.bat update --all --self'
Calls: ... latexmk_emu -> run_engine -> system2_quiet -> tlmgr_update
Além disso: Warning message:
In system2(..., stdout = if (use_file_stdout()) f1 else FALSE, stderr = f2) :
'CreateProcess' failed to run 'C:\Users\Glauco Gavioli\AppData\Roaming\TinyTeX\bin\win32\pdflatex.exe -halt-on-error -interaction=batchmode "Teste3.tex"'
Execução interrompida

No LaTeX installation detected (LaTeX is required to create PDF output). You should install a LaTeX distribution for your platform: htps://www.latex-project.org/get/

If you are not sure, you may install TinyTeX in R: tinytex::install_tinytex()

Otherwise consider MiKTeX on Windows - http://miktex.org

MacTeX on macOS - htps://tug.org/mactex/
(NOTE: Download with Safari rather than Chrome strongly recommended)

Linux: Use system package manager

Here is what I tryed so far:

1. Install tinytex package and install TinyTex distribution.

install.packages("tinytex")
tinytex::install_tinytex()

Result: nothing changed.

2. Checked if it was installed.

tinytex:::is_tinytex()
[1] TRUE

3. Tryed another option of installation.

devtools::install_github('yihui/tinytex')

Result: nothing changed.

4. Checked if it was installed again.

tinytex:::is_tinytex()
[1] TRUE

5. Tryed to uninstall and reinstall it some times.

tinytex::uninstall_tinytex()
remove.packages("tinytex")

6. Tryed to fix it since pdflatex.exe could not be found.

tinytex:::install_prebuilt()

7. Checking pdflatex.exe I got this:

file.info(tinytex:::win_app_dir('TinyTeX', 'bin', 'win32', 'pdflatex.exe'))

                                                                       size isdir mode               mtime

C:\Users\Glauco Gavioli\AppData\Roaming/TinyTeX/bin/win32/pdflatex.exe 1536 FALSE 777 2020-07-21 03:44:51
ctime
C:\Users\Glauco Gavioli\AppData\Roaming/TinyTeX/bin/win32/pdflatex.exe 2020-07-20 12:17:30
atime exe
C:\Users\Glauco Gavioli\AppData\Roaming/TinyTeX/bin/win32/pdflatex.exe 2020-07-21 03:44:51 win32

  1. Did some tests:

writeLines(c(

'\documentclass{article}',

'\begin{document}', 'Hello world!', '\end{document}'

), 'test.tex')

tinytex::pdflatex('test.tex')

Error in system2("tlmgr", args, ...) :
'CreateProcess' failed to run 'C:\Users\Glauco Gavioli\AppData\Roaming\TinyTeX\bin\win32\tlmgr.bat update --all --self'
Além disso: Warning message:
In system2(..., stdout = if (use_file_stdout()) f1 else FALSE, stderr = f2) :
'CreateProcess' failed to run 'C:\Users\Glauco Gavioli\AppData\Roaming\TinyTeX\bin\win32\pdflatex.exe -halt-on-error -interaction=batchmode "test.tex"'

9.Tryed older versions of tinytex package.

require(devtools)
install_version("tinytex", version = "0.19", repos = "https://cran.r-project.org")

Result: nothing changed. I'm still unable to knit to PDF.

I'm afraid I've ran out of options.

It's important to say that I restarted (close and open again) RStudion many times during this process, I tryed to substitute latex distribution TinyTex for MikTex (but didn't go well since the output was a different issue which didn't let me knit to PDF either) and I even tryed both installed together (TinyTex and MikTex). Then I uninstalled MikTek.

Hope someone could help me. I thank you beforehand.

Here are some info about my enviroment:

sessionInfo()

R version 4.0.2 (2020-06-22)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 18362)

Matrix products: default

locale:
[1] LC_COLLATE=Portuguese_Brazil.1252 LC_CTYPE=Portuguese_Brazil.1252 LC_MONETARY=Portuguese_Brazil.1252
[4] LC_NUMERIC=C LC_TIME=Portuguese_Brazil.1252

attached base packages:
[1] stats graphics grDevices utils datasets methods base

loaded via a namespace (and not attached):
[1] tinytex_0.24.1 tidyselect_1.1.0 xfun_0.15 remotes_2.1.1 purrr_0.3.4
[6] colorspace_1.4-1 vctrs_0.3.2 generics_0.0.2 testthat_2.3.2 usethis_1.6.1
[11] htmltools_0.5.0 yaml_2.2.1 rlang_0.4.7 pkgbuild_1.1.0 pillar_1.4.6
[16] later_1.1.0.1 glue_1.4.1 withr_2.2.0 statsr_0.2.1 sessioninfo_1.1.1
[21] lifecycle_0.2.0 munsell_0.5.0 gtable_0.3.0 devtools_2.3.0 evaluate_0.14
[26] memoise_1.1.0 knitr_1.29 fastmap_1.0.1 callr_3.4.3 httpuv_1.5.4
[31] ps_1.3.3 fansi_0.4.1 Rcpp_1.0.5 xtable_1.8-4 backports_1.1.8
[36] scales_1.1.1 promises_1.1.1 BiocManager_1.30.10 desc_1.2.0 pkgload_1.1.0
[41] mime_0.9 fs_1.4.2 ggplot2_3.3.2 digest_0.6.25 processx_3.4.3
[46] dplyr_1.0.0 shiny_1.5.0 grid_4.0.2 rprojroot_1.3-2 cli_2.0.2
[51] tools_4.0.2 magrittr_1.5 tibble_3.0.3 crayon_1.3.4 pkgconfig_2.0.3
[56] ellipsis_0.3.1 prettyunits_1.1.1 assertthat_0.2.1 rmarkdown_2.3 rstudioapi_0.11
[61] R6_2.4.1 compiler_4.0.2

Hello Glauco,

I see that you have a Windows user name containing a space.
This could be the reason for your problems.
Do a search for 'windows username spaces' in the search box on this page to find similar problems and hopefully a solution.

1 Like

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