2

I'm writing a paper in RMarkdown and for better reproducibility, I want to containerize all required software in a singularity container. Unfortunately, when I try to install TinyTeX (which is recommended for Rmarkdown and I would prefer over TeXLive to not inflate the container more than needed), it fails with the following error message (the full build log is pasted here):

Can't locate TeXLive/TLConfig.pm in @INC (you may need to install the TeXLive::TLConfig module) (@INC contains: /~/.TinyTeX/texmf-dist/scripts/texlive /~/.TinyTeX/tlpkg /etc/perl /usr/local/lib/x86_64-linux-gnu/perl/5.26.1 /usr/local/share/perl/5.26.1 /usr/lib/x86_64-linux-gnu/perl5/5.26 /usr/share/perl5 /usr/lib/x86_64-linux-gnu/perl/5.26 /usr/share/perl/5.26 /usr/local/lib/site_perl /usr/lib/x86_64-linux-gnu/perl-base) at ~/.TinyTeX/bin/x86_64-linux/tlmgr line 100.
BEGIN failed--compilation aborted at ~/.TinyTeX/bin/x86_64-linux/tlmgr line 100.

This is the build definition file, basically it uses a very slimmed down ubuntu 18.04 and then executes the %post section to install software

BootStrap: library
From: ubuntu:18.04

%post
  # Add universe repository
  echo "deb http://us.archive.ubuntu.com/ubuntu bionic universe" >> /etc/apt/sources.list
  apt -y update
  # Install utilites
  apt install -y wget
  # Install R
  apt install -y r-base-core
  ## Install RMarkdown and TinyTeX
  R --slave -e 'install.packages(c("rmarkdown","tinytex")); tinytex::install_tinytex()'

  # Clean
  apt-get clean

%environment
  export LC_ALL="en_US.UTF-8"

%labels
  Author DP

I have also tried tinytex::install_tinytex(dir="/opt/tinytex") but that didn't seem to change anything. Does anyone have an idea what's wrong?

DP.
  • 581
  • 4
  • 15

2 Answers2

2

That error message is complaining that your image (or, more likely, your path) is missing the TeXLive::TLConfig perl module.

My guess is that the path contents are not being rehashed with the installed modules after the install. The simplest solution is to break it into two commands:

R --slave -e 'install.packages(c("rmarkdown","tinytex"))'
R --slave -e 'tinytex::install_tinytex()'

Installation succeeds when I try that locally.

tsnowlan
  • 3,472
  • 10
  • 15
  • I still got the error (R 4.0 and Ubuntu 20.04). It also persists when I install by putting `wget -qO- "https://yihui.org/gh/tinytex/tools/install-unx.sh" | sh` in %post`. – Frank May 06 '20 at 21:13
0

A potentially useful alternative, if the image is just for document generation, could be converting a docker image with rmarkdown and tex (e.g. https://hub.docker.com/r/rocker/verse) to a singularity one.

With singularity pull docker://rocker/verse you can do that for the latest version, or for a specific version with verse:version_number.

vuzun
  • 942
  • 2
  • 8
  • 15
  • Thank you, but it's unfortunately not only for the document creation; the whole data analysis will be containerized as well to make the whole paper (and the results themselves) reproducible and give people a way of easily using our analysis methods on their own data. – DP. Aug 14 '19 at 12:45