2

I'm trying to knit a R markdown file to a html/pdf document. This is the error message that I'm getting:

output file: test.knit.md

pandoc.exe: test.utf8.md: openBinaryFile: does not exist (No such file or directory)
Error: pandoc document conversion failed with error 1
Execution halted

No LaTeX installation detected (LaTeX is required to create PDF output). You should install a LaTeX distribution for your platform: https://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 - https://tug.org/mactex/
  (NOTE: Download with Safari rather than Chrome _strongly_ recommended)

  Linux: Use system package manager

I'm using the most recent version of R, Rstudio, and tinytex packages, and I'm not working on a network drive (i.e. the Rmd file is located in C:/).

I have re-installed tinytex which resulted in some error messages:

tinytex::reinstall_tinytex()
If reinstallation fails, try install_tinytex() again. Then install the following packages:

tinytex::tlmgr_install(c("'\\ad.helsinki.fi\home\a\ann\Documents'", "CMD.EXE was started with the above path as the current directory.", "UNC paths are not supported.  Defaulting to Windows directory.", "amsfonts", "amsmath", "atbegshi", "atveryend", "auxhook", "babel", "bibtex", "bigintcalc", "bitset", "booktabs", "cm", "dehyph", "dvipdfmx", "dvips", "ec", "epstopdf-pkg", "etex", "etexcmds", "etoolbox", "euenc", "fancyvrb", "filehook", "firstaid", "float", "fontspec", "framed", "geometry", "gettitlestring", "glyphlist", "graphics", "graphics-cfg", "graphics-def", "grffile", "helvetic", "hycolor", "hyperref", "hyph-utf8", "hyphen-base", "iftex", "inconsolata", "infwarerr", "intcalc", "knuth-lib", "kpathsea", "kvdefinekeys", "kvoptions", "kvsetkeys", "l3backend", "l3kernel", "l3packages", "latex", "latex-amsmath-dev", "latex-bin", "latex-fonts", "latex-tools-dev", "latexconfig", "latexmk", "letltxmacro", "lm", "lm-math", "ltxcmds", "lua-alt-getopt", "luahbtex", "lualatex-math", "lualibs", "luaotfload", "luatex", "mdwtools", "metafont", "mfware", "modes", "ms", "natbib", "path", "pdfescape", "pdftex", "pdftexcmds", "plain", "refcount", "rerunfilecheck", "scheme-infraonly", "stringenc", "tex", "tex-ini-files", "texlive-scripts", "texlive.infra", "times", "tipa", "tlgs", "tlperl", "tlpsv", "tools", "unicode-data", "unicode-math", "uniquecounter", "url", "was", "xcolor", "xetex", "xetexconfig", "xkeyval", "xunicode", "zapfding"))

The directory C:\Users\ann\AppData\Roaming\TinyTeX/texmf-local is not empty. It will be backed up to C:\Users\ann\AppData\Local\Temp\RtmpWqoDNm\file1d1050f4326e and restored later.

tlmgr conf auxtrees remove "C:/PROGRA~1/R/R-40~1.3/share/texmf"
'\\ad.helsinki.fi\home\a\ann\Documents'
CMD.EXE was started with the above path as the current directory.
UNC paths are not supported.  Defaulting to Windows directory.
'\\ad.helsinki.fi\home\a\ann\Documents'
CMD.EXE was started with the above path as the current directory.
UNC paths are not supported.  Defaulting to Windows directory.
tlmgr conf auxtrees add "C:/PROGRA~1/R/R-40~1.3/share/texmf"
tlmgr install '\\ad.helsinki.fi\home\a\ann\Documents' CMD.EXE was started with the above path as the current directory. UNC paths are not supported.  Defaulting to Windows directory. path was
tlmgr.pl install: package '\\ad.helsinki.fi\home\a\ann\Documents' not present in repository.
tlmgr.pl install: package CMD.EXE not present in repository.
tlmgr.pl install: package Defaulting not present in repository.
tlmgr.pl install: package UNC not present in repository.
tlmgr.pl install: package Windows not present in repository.
tlmgr.pl install: package above not present in repository.
tlmgr.pl install: package are not present in repository.
tlmgr.pl install: package as not present in repository.
tlmgr.pl install: package current not present in repository.
tlmgr.pl install: package directory. not present in repository.
tlmgr.pl install: package not not present in repository.
tlmgr.pl install: package paths not present in repository.
tlmgr.pl install: package started not present in repository.
tlmgr.pl install: package supported. not present in repository.
tlmgr.pl install: package the not present in repository.
tlmgr.pl install: package to not present in repository.
tlmgr.pl install: package with not present in repository.
tlmgr.pl: package repository http://ctan.math.utah.edu/ctan/tex-archive/systems/texlive/tlnet (not verified: gpg unavailable)
[1/2, ??:??/??:??] install: path [6k]
[2/2, 00:00/00:00] install: was [4k]
tlmgr.pl: action install returned an error; continuing.
running mktexlsr ...
done running mktexlsr.
tlmgr.pl: An error has occurred. See above messages. Exiting.
tlmgr.pl: package log updated: C:/Users/ann/AppData/Roaming/TinyTeX/texmf-var/web2c/tlmgr.log
tlmgr update --self
tlmgr install '\\ad.helsinki.fi\home\a\ann\Documents' CMD.EXE was started with the above path as the current directory. UNC paths are not supported.  Defaulting to Windows directory. path was
tlmgr.pl install: package '\\ad.helsinki.fi\home\a\ann\Documents' not present in repository.
tlmgr.pl install: package CMD.EXE not present in repository.
tlmgr.pl install: package Defaulting not present in repository.
tlmgr.pl install: package UNC not present in repository.
tlmgr.pl install: package Windows not present in repository.
tlmgr.pl install: package above not present in repository.
tlmgr.pl install: package are not present in repository.
tlmgr.pl install: package as not present in repository.
tlmgr.pl install: package current not present in repository.
tlmgr.pl install: package directory. not present in repository.
tlmgr.pl install: package not not present in repository.
tlmgr.pl install: package paths not present in repository.
tlmgr.pl install: package started not present in repository.
tlmgr.pl install: package supported. not present in repository.
tlmgr.pl install: package the not present in repository.
tlmgr.pl install: package to not present in repository.
tlmgr.pl install: package with not present in repository.
tlmgr.pl: action install returned an error; continuing.
tlmgr.pl: package repository http://ctan.math.utah.edu/ctan/tex-archive/systems/texlive/tlnet (not verified: gpg unavailable)
tlmgr.pl install: package already present: path
tlmgr.pl install: package already present: was
tlmgr.pl: An error has occurred. See above messages. Exiting.

Based on advice in here I tried to verify if R can find the programs needed for knitting. It seems that it cannot find them.

Sys.which('pdflatex')
pdflatex 
      "" 

Further, it seems like the tinytex path wasn't added to the system environment variable PATH because the tinytex_root() path is not found in Sys.getenv('PATH') (see e.g. here).

tinytex::tinytex_root()
[1] "C:\\Users\\ann\\AppData\\Roaming\\TinyTeX"

 Sys.getenv('PATH')
[1] "C:\\Program Files\\R\\R-4.0.3\\bin\\x64;C:\\Program Files\\ImageMagick-7.0.8-Q16;C:\\Program Files (x86)\\Intel\\iCLS Client\\;C:\\Program Files\\Intel\\iCLS Client\\;C:\\WINDOWS\\system32;C:\\WINDOWS;C:\\WINDOWS\\System32\\Wbem;C:\\WINDOWS\\System32\\WindowsPowerShell\\v1.0\\;C:\\Program Files (x86)\\Intel\\Intel(R) Management Engine Components\\DAL;C:\\Program Files\\Intel\\Intel(R) Management Engine Components\\DAL;C:\\Program Files (x86)\\Intel\\Intel(R) Management Engine Components\\IPT;C:\\Program Files\\Intel\\Intel(R) Management Engine Components\\IPT;C:\\Program Files\\Microsoft VS Code\\bin;C:\\Program Files (x86)\\Windows Kits\\8.1\\Windows Performance Toolkit\\;C:\\Users\\hriihima\\AppData\\Local\\Continuum\\anaconda3;C:\\WINDOWS\\System32\\OpenSSH\\;C:\\Program Files (x86)\\NVIDIA Corporation\\PhysX\\Common;C:\\Program Files\\Git\\cmd;C:\\HYAPP\\rtools3.5\\bin;C:\\HYAPP\\rtools3.5\\gcc-4.6.3\\bin;C:\\HYAPP\\rtools3.5\\mingw_32\\bin;C:\\HYAPP\\rtools3.5\\mingw_64\\bin;C:\\Program Files\\PuTTY\\;C:\\Program Files\\Common Files\\ThinPrint\\;C:\\Users\\ann\\AppData\\Local\\Microsoft\\WindowsApps;"

Here's my session info:

> xfun::session_info()
R version 4.0.3 (2020-10-10)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 17763)

Locale:
  LC_COLLATE=Finnish_Finland.1252  LC_CTYPE=Finnish_Finland.1252    LC_MONETARY=Finnish_Finland.1252 LC_NUMERIC=C                    
  LC_TIME=Finnish_Finland.1252    

Package version:
  base64enc_0.1.3 compiler_4.0.3  digest_0.6.27   evaluate_0.14   glue_1.4.2      graphics_4.0.3  grDevices_4.0.3 highr_0.8       htmltools_0.5.0
  jsonlite_1.7.1  knitr_1.30      magrittr_1.5    markdown_1.1    methods_4.0.3   mime_0.9        remotes_2.2.0   rlang_0.4.8     rmarkdown_2.5  
  stats_4.0.3     stringi_1.5.3   stringr_1.4.0   tinytex_0.26    tools_4.0.3     utils_4.0.3     xfun_0.18       yaml_2.2.1  

EDITED: Installing tinytex again doesn't help either, I get the same error message from knitting. This is what is printed after the installation:

tinytex::install_tinytex()
trying URL 'https://yihui.org/tinytex/TinyTeX-1.zip'
Content type 'application/octet-stream' length 99792951 bytes (95.2 MB)
downloaded 95.2 MB

tlmgr conf auxtrees add "C:/PROGRA~1/R/R-40~1.3/share/texmf"
tlmgr install path was
tlmgr.pl: package repository https://mirror.las.iastate.edu/tex-archive/systems/texlive/tlnet (not verified: gpg unavailable)
[1/2, ??:??/??:??] install: path [6k]
[2/2, 00:01/00:01] install: was [4k]
running mktexlsr ...
done running mktexlsr.
tlmgr.pl: package log updated: C:/Users/annvirkk/AppData/Roaming/TinyTeX/texmf-var/web2c/tlmgr.log

After the installation of MiKTeX, I'm no longer seeing the Latex issue when I'm knitting the document, but the first error related to the openBinaryFile is still there. This is my example Rmd script:

---
title: "test"
output:
  html_document: default
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```


testing

```{r}

print("hi")


### 1. Testing



```

And this is the error message that it prints out:

output file: test.knit.md

pandoc.exe: test.utf8.md: openBinaryFile: does not exist (No such file or directory)
Error: pandoc document conversion failed with error 1
Execution halted

How can I fix these issues to be able to knit my Rmarkdown document? Thanks for help!

double-beep
  • 5,031
  • 17
  • 33
  • 41
Anna
  • 21
  • 3
  • as the error suggest, try to install it again this way: `tinytex::install_tinytex()` – Edo Oct 29 '20 at 13:33
  • 1
    Two issues were mixed up in this case. One is that LaTeX was not installed originally, and you fixed it (the output of `tinytex::tinytex_root()` shows that you installed TinyTeX correctly, and it doesn't have to be in the `PATH` variable). The other is that you seem to be on a network drive. This is a know issue in rmarkdown: https://github.com/rstudio/rmarkdown/issues/1268 And this comment in that thread might help: https://github.com/rstudio/rmarkdown/issues/1268#issuecomment-651784184 We will investigate this issue further in the near future. Thanks! – Yihui Xie Oct 29 '20 at 14:29
  • Thanks everyone. I tried Edo's and Daniel's suggestions, but that didn't help. Regarding Yihui's comment - my R markdown comment is located in C:/Documents/ folder so I don't think I'm on a network drive. Or am I understanding this incorrectly? – Anna Oct 29 '20 at 14:42
  • Sorry - I think the Documents folder is on a network drive after all so I'll try Yihui's suggestion now. – Anna Oct 29 '20 at 14:49
  • Yes, the issue was related to network drives. And the problem is now fixed. Thanks all! – Anna Oct 29 '20 at 14:58
  • Welcome to Stack Overflow! I'm glad you found a solution to your problem. However, an actual answer/solution should **not** be edited into your question. In general, you should [edit] the question to *clarify* it, but not to include an answer within it. You should create your own answer with the code/solution you used to solve your problem, and then accept it (the system may require a 48 hour delay prior to doing so). When you've solved the problem yourself, [answering your own question is encouraged](/help/self-answer). – double-beep Oct 29 '20 at 15:03

1 Answers1

0

also can try installing Miketex too, also like Edo said, install tinytex like Rmarkdown suggests.

Obvious your issue is just that latex is not installed, so just try reinstalling and installing another latex program and you should be good to knit!

Daniel_j_iii
  • 3,041
  • 2
  • 11
  • 27