rocker-org / rocker-versioned

Run current & prior versions of R using docker
https://hub.docker.com/r/rocker/r-ver
GNU General Public License v2.0
297 stars 169 forks source link

Note to self: Consider tinytex for verse image #59

Closed cboettig closed 6 years ago

cboettig commented 6 years ago

See: https://github.com/yihui/tinytex, as referenced in: https://github.com/rstudio/rticles/pull/130#issuecomment-313583364.

In the near future, we will add the tinytex support in the rmarkdown package, so that R users will rarely need to worry about LaTeX maintenance issues (missing packages will be automatically installed) and can really focus on writing.

cboettig commented 6 years ago

https://github.com/yihui/tinytex/issues/1

eddelbuettel commented 6 years ago

It always makes me cringe a little when people re-invent Debian in small pieces. If I were you I'd probably start talking to Norbert about how to do this within tex-live. Remember that we here in Rocker have a much more direct access to OS-level facilities (as we know full well which containers we are based on) than an R-level add-on like tinytex could ever have as it needs to reinvent everything across three or more OSs.

wch commented 6 years ago

FWIW, I've used this in a Dockerfile with success. It installs the necessary packages to build R from source:

# Install TinyTeX (subset of TeXLive)
# From FAQ 5 and 6 here: https://yihui.name/tinytex/faq/
# Also install ae, parskip, and listings packages to build R's vignettes
RUN wget -qO- \
    "https://github.com/yihui/tinytex/raw/master/tools/install-unx.sh" | \
    sh -s - --admin --no-path \
    && ~/.TinyTeX/bin/*/tlmgr path add \
    && tlmgr install metafont mfware inconsolata tex ae parskip listings \
    && tlmgr path add \
    && Rscript -e "source('https://install-github.me/yihui/tinytex'); tinytex::r_texmf()"

A few notes:

eddelbuettel commented 6 years ago

Somewhat naive question: Why can one not just use /usr/bin/tlmgr ? Ships with texlive-base. Or is that already considered "too big"? Is the motivation to do an Alpine and shrink size?

cboettig commented 6 years ago

Thanks @wch, @yihui and I have also been discussing this over in https://github.com/yihui/tinytex/issues/1. My only variation to your proposal is what is now basically FAQ 9: I think in the setup you show only the root user can add additional tex packages still(?)

To answer Dirk's question, I think for me a major motivation to adopt TinyTex on the verse image is that most users use this image exclusively in RStudio and without enabling sudo for their user, and thus don't have an easy way to add tex packages when they want to use some template from rticles etc. Being able to add those from R (or possibly even automatically) will be much more accessible to most users then saying "just docker exec in and install the package", or download the package manually from texlive.

Though smaller size is quite nice too, one of the main reasons we created the separate verse image on top of tidyverse is so that users of the latter could escape the overhead of texlive bits. (I also agree with Dirk that Alpine's musl libc is more pain than it's worth for any non-trivial environment -- try getting RStudio to build w/o glibc!)

cboettig commented 6 years ago

Well here's a puzzle! Apparently I cannot run a simple mv command in sh shell / Docker RUN? But works fine in bash?

Try building this image. See https://github.com/rocker-org/rocker-versioned/blob/63497f11ffdd6750ddee45f910890a81ef3c7a7f/verse/Dockerfile#L47-L52

yihui commented 6 years ago

@cboettig It is ~/.TinyTeX (capital X) instead of ~/.TinyTex. (BTW, many people write LaTeX as LaTex, and @kbroman's theory seems convincing to me.)

eddelbuettel commented 6 years ago

Copyright "LaTeX Project Public License"

"Many people" have been found wrong before. One works in the example below, and one doesn't:

\documentclass[12pt]{article}
\begin{document}

\LaTeX

%\LaTex

\end{document}
cboettig commented 6 years ago

ha, I can't type late at night apparently. @yihui Quick question -- I've given the user recursive write & execute permission over all of /opt/TinyTeX, but I still get an error when the user tries to install fonts:

tar: fonts/vf/adobe: Cannot mkdir: Permission denied

Where is it trying to install fonts? Are these being placed in the global system fonts instead of somewhere in /opt/TinyTeX?

See https://github.com/rocker-org/rocker-versioned/blob/88cd3314927855931d8f8138e2404bfc64aa7e6d/verse/Dockerfile#L36-L45

yihui commented 6 years ago

TinyTeX is a portable version of TeX Live, which means everything stays in /opt/TinyTeX (except that symlinks are created under /usr/local/bin). Typically fonts should be installed to the texmf-dist/fonts directory under the TinyTeX root directory. It sounds to me that the user does not have write permission to this directory?

cboettig commented 6 years ago

@yihui ah, I see what is happening.

/opt/TinyTeX/texmf-dist/fonts is in the staff group already, but it looks like some of the subdirectories there are only being created by Line 43 installs (run by root), which come after my chmod call on line 41. I'll switch the order and I think that should fix it. Thanks for the hint about where it looks for fonts!

yihui commented 6 years ago

@cboettig Cool. BTW, I'm not sure, but +x is probably not necessary on all the subdirectories. All executables are under the /opt/TinyTeX/bin/*/ subdirectory. You might want to be a little more conservative.

cboettig commented 6 years ago

Thanks @yihui, done.

Okay, PR for proposed TinyTex here: https://github.com/rocker-org/rocker-versioned/pull/60, would love any other comments on that before I merge.

cboettig commented 6 years ago

Merged! tinytex should now be available in verse:latest and it's descendants.