> So maybe it is indirectly called via some other R function .. hard to > say. In any case, *this*should*not*be*done*. > > It would be nice to find out who actually called tlmgr. If you could > manage to find this it would help a lot. Thanks
After many hours of digging (sigh): It is the function tinytex::latexmk. Long story (unfortunately not so) short, if a user calls Rscript -e 'rmarkdown::render("test.rmd", "pdf_document")' on some R markdown file (it is enough to have just the word "Test" in it) on stretch system with the necessary texlive packages installed, except e.g. for the package lmodern, then he gets user@box:~/tmp/test$ Rscript -e 'rmarkdown::render("test.rmd", "pdf_document")' processing file: test.rmd |.................................................................| 100% ordinary text without R code output file: test.knit.md /usr/bin/pandoc +RTS -K512m -RTS test.utf8.md --to latex --from markdown +autolink_bare_uris+ascii_identifiers+tex_math_single_backslash --output test.tex --template /usr/local/lib/R/site-library/rmarkdown/rmd/latex/ default-1.17.0.2.tex --highlight-style tango --latex-engine pdflatex --variable graphics=yes --variable 'geometry:margin=1in' You are recommended to install the tinytex package to build PDF.FALSE This is pdfTeX, Version 3.14159265-2.6-1.40.17 (TeX Live 2016/Debian) (preloaded format=pdflatex) restricted \write18 enabled. entering extended mode ! LaTeX Error: File `lmodern.sty' not found. ... So at this point the user can a) find out e.g. using apt-file which Debian package provides lmodern.sty (which is what I have done in earlier times), or b) install the R package tinytex as recommended above [1,2] If the user chooses b), and then tries again, he gets ... /usr/bin/pandoc +RTS -K512m -RTS test.utf8.md --to latex --from markdown +autolink_bare_uris+ascii_identifiers+tex_math_single_backslash --output test.tex --template /usr/local/lib/R/site-library/rmarkdown/rmd/latex/ default-1.17.0.2.tex --highlight-style tango --latex-engine pdflatex --variable graphics=yes --variable 'geometry:margin=1in' tlmgr search --file --global '/lmodern.sty' Cannot determine type of tlpdb from /home/user/texmf! cannot setup TLPDB in /home/user/texmf at /usr/bin/tlmgr line 5713. ! LaTeX Error: File `lmodern.sty' not found. ! Emergency stop. <read *> Error: Failed to compile test.tex. See test.log for more info. In addition: Warning messages: 1: running command ''tlmgr' search --file --global '/lmodern.sty'' had status 2 2: In parse_packages(logfile, quiet = c(TRUE, FALSE, FALSE)) : Failed to find a package that contains lmodern.sty Execution halted So when a user than goes on to try to get tlmgr to do the work, and issues user@box: tlmgr init-usertree he gets: (running on Debian, switching to user mode!) Cannot determine type of tlpdb from /home/user/texmf! Then the user scratches his head. Either he will consult a commonly used search engine, and read through some stackoverflow postings, or just try the rendering again, which will yield: ... /usr/bin/pandoc +RTS -K512m -RTS test.utf8.md --to latex --from markdown +autolink_bare_uris+ascii_identifiers+tex_math_single_backslash --output test.tex --template /usr/local/lib/R/site-library/rmarkdown/rmd/latex/ default-1.17.0.2.tex --highlight-style tango --latex-engine pdflatex --variable graphics=yes --variable 'geometry:margin=1in' tlmgr search --file --global '/lmodern.sty' /usr/bin/tlmgr: Initialization failed (in setup_unix_one): /usr/bin/tlmgr: could not find a usable xzdec. /usr/bin/tlmgr: Please install xzdec and try again. tlmgr: Couldn't set up the necessary programs. Installation of packages is not supported. Please report to texl...@tug.org. tlmgr: Continuing anyway ... Use of uninitialized value $r in split at /usr/bin/tlmgr line 3899. tlmgr: Cannot find main repository, you have to tag one as main! ! LaTeX Error: File `lmodern.sty' not found. ... So he thinks, yay, I will just install xzdec and all will be good, which will then yield: ... /usr/bin/pandoc +RTS -K512m -RTS test.utf8.md --to latex --from markdown +autolink_bare_uris+ascii_identifiers+tex_math_single_backslash --output test.tex --template /usr/local/lib/R/site-library/rmarkdown/rmd/latex/ default-1.17.0.2.tex --highlight-style tango --latex-engine pdflatex --variable graphics=yes --variable 'geometry:margin=1in' tlmgr search --file --global '/lmodern.sty' Trying to automatically install missing LaTeX packages... tlmgr install lm (running on Debian, switching to user mode!) tlmgr: package repository http://ftp.fau.de/ctan/systems/texlive/tlnet (verified) [1/1, ??:??/??:??] install: lm [11651k] tlmgr: package log updated: /home/jranke/texmf/web2c/tlmgr.log running mktexlsr ... done running mktexlsr. running updmap ... done running updmap. tlmgr path add (running on Debian, switching to user mode!) tlmgr: action `path' not supported in usermode! Output created: test.pdf Side remark: I do share Yihui's wish [2] to avoid installing some of the huge packages (e.g. texlive-fonts-extra, texlive-latex-extra) when I set up a system for compiling R markdown documents. However, I think the tinytex package is currently not explicit enough about what it is doing. For example, I was not surprised to find some tlmgr related files and directories in ~/texmf. But only through reading a different bug report [3] I found out that it installed into ~/.texlive2016. My conclusion regarding texlive-base: I still think that texlive-base should depend on xzdec, as it provides /usr/bin/tlmgr which does not seem to work without it. Cheers, Johannes [1] https://github.com/rstudio/rmarkdown/blob/master/R/util.R#L315 [2] https://yihui.name/tinytex [3] https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=856020