miraisolutions / SmaRP

Shiny app for projecting retirement funds / benefits
https://mirai-solutions.ch/gallery/smarp
20 stars 9 forks source link

No PNG images with new TeXLive: Use version-stable TinyTeX #152

Closed riccardoporreca closed 4 years ago

riccardoporreca commented 4 years ago

There is an issue when running SmaRP from the Docker container as the usual test in the release process: The PNG images of the Swiss pension system and Tax benefits in the PDF report are not shown.

Originally posted by @riccardoporreca in https://github.com/miraisolutions/SmaRP/pull/151#issuecomment-548729687

After some investigation, the root cause is a problem recently introduced in the graphicx LaTeX package (see jgm/pandoc#5848), preventing images to be included with the xelatex engine we currently use for the PDF report.

There is a fundamental issue with the way we use TeXLive (via TinyTeX, see #91), which is meant to always install the latest version of TeXLive and LaTeX packages. This is unfortunately a source of issue since in any new build of SmaRP as new versions will kick-in in a possibly uncontrolled way. This is sort of against the version-stable approach behind the version-stable Rocker images we leverage on. Note that the version-stable Rocker images use the same approach to the TinyTeX installation we use in SmaRP and hence are subject to similar problems => see corresponding issue rocker-org/rocker-versioned#169

There is however good news: A tlnet archive is now available with TeXLive snaphots of CTAN (similar to the MRAN), see also https://www.tug.org/texlive/pkginstall.html. TinyTex in fact supports specifying a custom CTAN repo via the environment variable CTAN_REPO: https://github.com/yihui/tinytex/blob/9efbce0c77179eac2f6800f08b768aefa1917085/tools/install-base.sh#L5 so we could set it to make our TinyTeX install version-stable.

riccardoporreca commented 4 years ago

Usage of version-stable TinyTeX implemented with 0a69df4 in a feature branch, where we use as date 2019/02/27, which is the latest snapshot available before the MRAN build date of the rocker/r-ver:3.5.3 we are currently using and corresponds to the frozen 2018 TeXLive snapshot.

Successfully tested in the feature branch via

git checkout feature/152-version-stable-tinytex
docker build --pull -f Dockerfile -t mirai/smarp:152-version-stable-tinytex .
docker run -p 80:80 mirai/smarp:152-version-stable-tinytex
riccardoporreca commented 4 years ago

Note that, in general, we shall reconsider if we want to keep using xelatex as engine, as well as whether PDF version (vector graphics) of the figures can be created and used instead of PNG.

This can be addressed as part of #130.

riccardoporreca commented 4 years ago

After some more thoughts, one option to pick the TeXLive snapshot is to bind it to the version of TeXLive normally shipped as texlive-* packages in the Debian image each rocker/r-ver is created FROM. This would basically mean using the TinyTeX install in the rocker/verse as a tiny, container-friendly replacement for the TeXLive install one would get via apt-get for the specific Debian release. The information can be found at https://www.tug.org/texlive/debian.html.

Originally posted by @riccardoporreca in https://github.com/rocker-org/rocker-versioned/issues/169#issuecomment-549568166

It then makes sense to use the TeXLive 2016 release from the tlnet archive, i.e. http://www.texlive.info/tlnet-archive/2017/04/13/tlnet as CTAN_REPO. Note the http instead of https, this is required since back in TeXLive 2016 install-tl only supported http and ftp for the -repository command-line argument.

This is even more relevant for SmaRP, where we are doing a first release where we switch from the debian texlive-* packages to TinyTeX, and this approach would minimize the difference in the PDF report due to the version of TeXLive and LaTeX packages.