rstudio / tinytex

A lightweight, cross-platform, portable, and easy-to-maintain LaTeX distribution based on TeX Live
https://yihui.org/tinytex/
Other
983 stars 116 forks source link

TinyTeX needs Perl #419

Closed mfansler closed 1 year ago

mfansler commented 1 year ago

This issue is to report a finding that on the Conda Forge CI (running on image quay.io/condaforge/linux-anvil-cos7-x86_64), we found that tinytex::install_tinytex() would result in error unless Perl was installed on the system. I realize most end-user systems will have this, but containers may not, and I did not see this expectation documented. I suggest it should be documented.

For replication, here are examples running with and without Perl.

Failure without Perl

Shell

$ docker run --rm -it mambaorg/micromamba:1.4.9
(base) $ micromamba install -yn base -c conda-forge r-base=4.3 r-tinytex
(base) $ R -e 'tinytex::install_tinytex()'

Result

```r R version 4.3.1 (2023-06-16) -- "Beagle Scouts" Copyright (C) 2023 The R Foundation for Statistical Computing Platform: x86_64-conda-linux-gnu (64-bit) R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > tinytex::install_tinytex() trying URL 'https://yihui.org/tinytex/TinyTeX-1.tar.gz' Content type 'application/octet-stream' length 92097989 bytes (87.8 MB) ================================================== downloaded 87.8 MB tlmgr option sys_bin ~/bin Can't locate File/Find.pm in @INC (you may need to install the File::Find module) (@INC contains: /home/mambauser/.TinyTeX/texmf-dist/scripts/texlive /home/mambauser/.TinyTeX/tlpkg /etc/perl /usr/local/lib/x86_64-linux-gnu/perl/5.32.1 /usr/local/share/perl/5.32.1 /usr/lib/x86_64-linux-gnu/perl5/5.32 /usr/share/perl5 /usr/lib/x86_64-linux-gnu/perl-base /usr/lib/x86_64-linux-gnu/perl/5.32 /usr/share/perl/5.32 /usr/local/lib/site_perl) at /home/mambauser/.TinyTeX/bin/x86_64-linux/tlmgr line 87. BEGIN failed--compilation aborted at /home/mambauser/.TinyTeX/bin/x86_64-linux/tlmgr line 87. Can't locate File/Find.pm in @INC (you may need to install the File::Find module) (@INC contains: /home/mambauser/.TinyTeX/texmf-dist/scripts/texlive /home/mambauser/.TinyTeX/tlpkg /etc/perl /usr/local/lib/x86_64-linux-gnu/perl/5.32.1 /usr/local/share/perl/5.32.1 /usr/lib/x86_64-linux-gnu/perl5/5.32 /usr/share/perl5 /usr/lib/x86_64-linux-gnu/perl-base /usr/lib/x86_64-linux-gnu/perl/5.32 /usr/share/perl/5.32 /usr/local/lib/site_perl) at /home/mambauser/.TinyTeX/bin/x86_64-linux/tlmgr line 87. BEGIN failed--compilation aborted at /home/mambauser/.TinyTeX/bin/x86_64-linux/tlmgr line 87. Can't locate File/Find.pm in @INC (you may need to install the File::Find module) (@INC contains: /home/mambauser/.TinyTeX/texmf-dist/scripts/texlive /home/mambauser/.TinyTeX/tlpkg /etc/perl /usr/local/lib/x86_64-linux-gnu/perl/5.32.1 /usr/local/share/perl/5.32.1 /usr/lib/x86_64-linux-gnu/perl5/5.32 /usr/share/perl5 /usr/lib/x86_64-linux-gnu/perl-base /usr/lib/x86_64-linux-gnu/perl/5.32 /usr/share/perl/5.32 /usr/local/lib/site_perl) at /home/mambauser/.TinyTeX/bin/x86_64-linux/tlmgr line 87. BEGIN failed--compilation aborted at /home/mambauser/.TinyTeX/bin/x86_64-linux/tlmgr line 87. Can't locate File/Find.pm in @INC (you may need to install the File::Find module) (@INC contains: /home/mambauser/.TinyTeX/texmf-dist/scripts/texlive /home/mambauser/.TinyTeX/tlpkg /etc/perl /usr/local/lib/x86_64-linux-gnu/perl/5.32.1 /usr/local/share/perl/5.32.1 /usr/lib/x86_64-linux-gnu/perl5/5.32 /usr/share/perl5 /usr/lib/x86_64-linux-gnu/perl-base /usr/lib/x86_64-linux-gnu/perl/5.32 /usr/share/perl/5.32 /usr/local/lib/site_perl) at /home/mambauser/.TinyTeX/bin/x86_64-linux/tlmgr line 87. BEGIN failed--compilation aborted at /home/mambauser/.TinyTeX/bin/x86_64-linux/tlmgr line 87. Can't locate File/Find.pm in @INC (you may need to install the File::Find module) (@INC contains: /home/mambauser/.TinyTeX/texmf-dist/scripts/texlive /home/mambauser/.TinyTeX/tlpkg /etc/perl /usr/local/lib/x86_64-linux-gnu/perl/5.32.1 /usr/local/share/perl/5.32.1 /usr/lib/x86_64-linux-gnu/perl5/5.32 /usr/share/perl5 /usr/lib/x86_64-linux-gnu/perl-base /usr/lib/x86_64-linux-gnu/perl/5.32 /usr/share/perl/5.32 /usr/local/lib/site_perl) at /home/mambauser/.TinyTeX/bin/x86_64-linux/tlmgr line 87. BEGIN failed--compilation aborted at /home/mambauser/.TinyTeX/bin/x86_64-linux/tlmgr line 87. Can't locate File/Find.pm in @INC (you may need to install the File::Find module) (@INC contains: /home/mambauser/.TinyTeX/texmf-dist/scripts/texlive /home/mambauser/.TinyTeX/tlpkg /etc/perl /usr/local/lib/x86_64-linux-gnu/perl/5.32.1 /usr/local/share/perl/5.32.1 /usr/lib/x86_64-linux-gnu/perl5/5.32 /usr/share/perl5 /usr/lib/x86_64-linux-gnu/perl-base /usr/lib/x86_64-linux-gnu/perl/5.32 /usr/share/perl/5.32 /usr/local/lib/site_perl) at /home/mambauser/.TinyTeX/bin/x86_64-linux/tlmgr line 87. BEGIN failed--compilation aborted at /home/mambauser/.TinyTeX/bin/x86_64-linux/tlmgr line 87. Can't locate File/Find.pm in @INC (you may need to install the File::Find module) (@INC contains: /home/mambauser/.TinyTeX/texmf-dist/scripts/texlive /home/mambauser/.TinyTeX/tlpkg /etc/perl /usr/local/lib/x86_64-linux-gnu/perl/5.32.1 /usr/local/share/perl/5.32.1 /usr/lib/x86_64-linux-gnu/perl5/5.32 /usr/share/perl5 /usr/lib/x86_64-linux-gnu/perl-base /usr/lib/x86_64-linux-gnu/perl/5.32 /usr/share/perl/5.32 /usr/local/lib/site_perl) at /home/mambauser/.TinyTeX/bin/x86_64-linux/tlmgr line 87. BEGIN failed--compilation aborted at /home/mambauser/.TinyTeX/bin/x86_64-linux/tlmgr line 87. tlmgr option repository 'https://mirror.mwt.me/ctan/systems/texlive/tlnet' Can't locate File/Find.pm in @INC (you may need to install the File::Find module) (@INC contains: /home/mambauser/.TinyTeX/texmf-dist/scripts/texlive /home/mambauser/.TinyTeX/tlpkg /etc/perl /usr/local/lib/x86_64-linux-gnu/perl/5.32.1 /usr/local/share/perl/5.32.1 /usr/lib/x86_64-linux-gnu/perl5/5.32 /usr/share/perl5 /usr/lib/x86_64-linux-gnu/perl-base /usr/lib/x86_64-linux-gnu/perl/5.32 /usr/share/perl/5.32 /usr/local/lib/site_perl) at /home/mambauser/.TinyTeX/bin/x86_64-linux/tlmgr line 87. BEGIN failed--compilation aborted at /home/mambauser/.TinyTeX/bin/x86_64-linux/tlmgr line 87. tlmgr update --list Can't locate File/Find.pm in @INC (you may need to install the File::Find module) (@INC contains: /home/mambauser/.TinyTeX/texmf-dist/scripts/texlive /home/mambauser/.TinyTeX/tlpkg /etc/perl /usr/local/lib/x86_64-linux-gnu/perl/5.32.1 /usr/local/share/perl/5.32.1 /usr/lib/x86_64-linux-gnu/perl5/5.32 /usr/share/perl5 /usr/lib/x86_64-linux-gnu/perl-base /usr/lib/x86_64-linux-gnu/perl/5.32 /usr/share/perl/5.32 /usr/local/lib/site_perl) at /home/mambauser/.TinyTeX/bin/x86_64-linux/tlmgr line 87. BEGIN failed--compilation aborted at /home/mambauser/.TinyTeX/bin/x86_64-linux/tlmgr line 87. tlmgr option repository ctan Can't locate File/Find.pm in @INC (you may need to install the File::Find module) (@INC contains: /home/mambauser/.TinyTeX/texmf-dist/scripts/texlive /home/mambauser/.TinyTeX/tlpkg /etc/perl /usr/local/lib/x86_64-linux-gnu/perl/5.32.1 /usr/local/share/perl/5.32.1 /usr/lib/x86_64-linux-gnu/perl5/5.32 /usr/share/perl5 /usr/lib/x86_64-linux-gnu/perl-base /usr/lib/x86_64-linux-gnu/perl/5.32 /usr/share/perl/5.32 /usr/local/lib/site_perl) at /home/mambauser/.TinyTeX/bin/x86_64-linux/tlmgr line 87. BEGIN failed--compilation aborted at /home/mambauser/.TinyTeX/bin/x86_64-linux/tlmgr line 87. You may have to restart your system after installing TinyTeX to make sure ~/bin appears in your PATH variable (https://github.com/rstudio/tinytex/issues/16). Warning messages: 1: In system2("tlmgr", args, ...) : running command ''tlmgr' info --list --only-installed --data 'name'' had status 2 2: In tinytex::install_tinytex() : The repository https://mirror.mwt.me/ctan/systems/texlive/tlnet/ does not seem to be accessible. Reverting to the default CTAN mirror. > ```

Expected behavior with Perl

Shell

$ docker run --rm -it mambaorg/micromamba:1.4.9
(base) $ micromamba install -yn base -c conda-forge r-base=4.3 r-tinytex perl
(base) $ R -e 'tinytex::install_tinytex()'

Result

```r R version 4.3.1 (2023-06-16) -- "Beagle Scouts" Copyright (C) 2023 The R Foundation for Statistical Computing Platform: x86_64-conda-linux-gnu (64-bit) R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > tinytex::install_tinytex() trying URL 'https://yihui.org/tinytex/TinyTeX-1.tar.gz' Content type 'application/octet-stream' length 92097989 bytes (87.8 MB) ================================================== downloaded 87.8 MB tlmgr option sys_bin ~/bin tlmgr: setting option sys_bin to /home/mambauser/bin. tlmgr: updating /home/mambauser/.TinyTeX/tlpkg/texlive.tlpdb tlmgr option repository 'https://ctan.mirrors.hoobly.com/systems/texlive/tlnet' tlmgr: setting default package repository to https://ctan.mirrors.hoobly.com/systems/texlive/tlnet tlmgr: updating /home/mambauser/.TinyTeX/tlpkg/texlive.tlpdb tlmgr update --list tlmgr: package repository https://ctan.mirrors.hoobly.com/systems/texlive/tlnet (not verified: gpg unavailable) update: texlive-scripts [112k]: local: 67839, source: 67842 > ```

By filing an issue to this repo, I promise that

I understand that my issue may be closed if I don't fulfill my promises.

yihui commented 1 year ago

Can't locate File/Find.pm in @INC (you may need to install the File::Find module) (@INC contains: /home/mambauser/.TinyTeX/texmf-dist/scripts/texlive /home/mambauser/.TinyTeX/tlpkg /etc/perl /usr/local/lib/x86_64-linux-gnu/perl/5.32.1 /usr/local/share/perl/5.32.1 /usr/lib/x86_64-linux-gnu/perl5/5.32 /usr/share/perl5 /usr/lib/x86_64-linux-gnu/perl-base /usr/lib/x86_64-linux-gnu/perl/5.32 /usr/share/perl/5.32 /usr/local/lib/site_perl) at /home/mambauser/.TinyTeX/bin/x86_64-linux/tlmgr line 87.

@norbusan I wonder if this error message could be improved when Perl is not present in the system. I don't know much about Perl, and I have no idea what this error message means. Thanks!

mfansler commented 1 year ago

On second glance, looks like I was a bit hasty concluding that Perl wasn't installed in the first container. Rather, that error message is complaining that the File::Find module is missing.

norbusan commented 1 year ago

I don't understand, File::Find is a core perl module, if you have Perl installed, that module should be installed, too.

mfansler commented 1 year ago

I don't understand, File::Find is a core perl module, if you have Perl installed, that module should be installed, too.

Apologies if I'm misinterpreting the error. 😬 (not a Perl person)

In the container I see:

$ docker run --rm -it mambaorg/micromamba:1.4.9
(base) $ which perl
/usr/bin/perl
(base) $ perl -v

This is perl 5, version 32, subversion 1 (v5.32.1) built for x86_64-linux-gnu-thread-multi
(with 47 registered patches, see perl -V for more detail)

Copyright 1987-2021, Larry Wall

Perl may be copied only under the terms of either the Artistic License or the
GNU General Public License, which may be found in the Perl 5 source kit.

Complete documentation for Perl, including FAQ lists, should be found on
this system using "man perl" or "perldoc perl".  If you have access to the
Internet, point your browser at http://www.perl.org/, the Perl Home Page.

(base) $ perl -mFile
Can't locate File.pm in @INC (you may need to install the File module) (@INC contains: /etc/perl /usr/local/lib/x86_64-linux-gnu/perl/5.32.1 /usr/local/share/perl/5.32.1 /usr/lib/x86_64-linux-gnu/perl5/5.32 /usr/share/perl5 /usr/lib/x86_64-linux-gnu/perl-base /usr/lib/x86_64-linux-gnu/perl/5.32 /usr/share/perl/5.32 /usr/local/lib/site_perl).
BEGIN failed--compilation aborted.

(base) $ perl -mFile::Find
Can't locate File/Find.pm in @INC (you may need to install the File::Find module) (@INC contains: /etc/perl /usr/local/lib/x86_64-linux-gnu/perl/5.32.1 /usr/local/share/perl/5.32.1 /usr/lib/x86_64-linux-gnu/perl5/5.32 /usr/share/perl5 /usr/lib/x86_64-linux-gnu/perl-base /usr/lib/x86_64-linux-gnu/perl/5.32 /usr/share/perl/5.32 /usr/local/lib/site_perl).
BEGIN failed--compilation aborted.

I interpret that as Perl 5.32.1 is installed, but not the File::Find module. Note that this is a container targeting production, i.e., it's not surprising to find extreme minimization.

norbusan commented 1 year ago

Thanks @mfansler Wow, that is really stripped down, and I consider this BADLY incorrect. The image you are using is based on Debian, and only has perl-base installed. To quote from https://packages.debian.org/bookworm/perl-modules-5.36

Architecture independent Perl modules. These modules are part of Perl and required if the `perl' package is installed.

Now, I agree that perl is not installed, only perl-base. But to be honest, this is badly broken because (to quote again):

Note that this package only exists to save archive space and should be considered an internal implementation detail of the perl package. Other packages should not depend on perl-modules-5.36 directly, they should use perl (which depends on perl-modules-5.36) instead.

So, as much as I understand your problem, I think this is purely a problem of a completely misconfigured docker image.

mfansler commented 1 year ago

Good to know!

I think for Conda Forge purposes I'm going to have the package emit a message at installation time informing users that tinytex::install_tinytex() requires a perl installation. We could go as far as requiring perl through Conda, but I think this is such an edge case (and, as you identify, substandard context) that it should rarely be encountered. I won't pursue getting the micromamba image adjusted. It suffices for the target application (micromamba) and when needed a proper perl can easily be added to any Conda environment, as shown by OP.

For purposes of this issue, my take is that:

Thanks for the feedback/insights! I appreciate that this is in no way urgent (you both certainly have more productive matters at hand!) and perhaps just having this issue filed is satisfactory documentation.

yihui commented 1 year ago

I just tested on macOS and it's odd that perl -mFile also fails but tinytex::install_tinytex() works fine.

% which perl
/usr/bin/perl

% perl -mFile      
Can't locate File.pm in @INC (you may need to install the File module) (@INC contains: /Library/Perl/5.30/darwin-thread-multi-2level /Library/Perl/5.30 /Network/Library/Perl/5.30/darwin-thread-multi-2level /Network/Library/Perl/5.30 /Library/Perl/Updates/5.30.3 /System/Library/Perl/5.30/darwin-thread-multi-2level /System/Library/Perl/5.30 /System/Library/Perl/Extras/5.30/darwin-thread-multi-2level /System/Library/Perl/Extras/5.30).
BEGIN failed--compilation aborted.
mfansler commented 1 year ago

Sorry, that part might have been misleading. File::Find being a module probably doesn't entail File being a module. I was just trying it out.

yihui commented 1 year ago

perl -mFile::Find hangs on my machine and there's no output. Not sure why.

mfansler commented 1 year ago

I believe it's waiting for input. Not sure what the standard is, but passing empty file (e.g., /dev/null) will get it going. Here's from macOS:

## not found
$ perl -mFile /dev/null
Can't locate File.pm in @INC (you may need to install the File module) (@INC contains: /Users/mfansler/miniconda3/lib/perl5/5.32/site_perl /Users/mfansler/miniconda3/lib/perl5/site_perl /Users/mfansler/miniconda3/lib/perl5/5.32/vendor_perl /Users/mfansler/miniconda3/lib/perl5/vendor_perl /Users/mfansler/miniconda3/lib/perl5/5.32/core_perl /Users/mfansler/miniconda3/lib/perl5/core_perl .).
BEGIN failed--compilation aborted.

## found
$ perl -mFile::Find /dev/null

So one could run something like:

$ perl -mFile::Find /dev/null 2> /dev/null

Then check that $? is 0.

yihui commented 1 year ago

Okay, that works. Thanks!

However, I think a better solution is to declare the dependency on perl for the (conda?) package r-tinytex. I prefer not having to manage this dependency inside an R function. I have no idea how conda packages are built, and don't know whom to contact in this case.

mfansler commented 1 year ago

I have no idea how conda packages are built, and don't know whom to contact in this case.

I'm on the Conda Forge R team. :wink:

However, I think a better solution is to declare the dependency on perl for the (conda?) package r-tinytex.

I hesitate to do this because it's a waste of 100 MB of disk space for users on desktop Linux or macOS (both have functional system Perl) and suspect they comprise the majority user base. I think an install message suffices for the DevOps people deploying to containers that actually need it. I'm only proposing to do this on the Conda Forge feedstock and requires nothing to be done here.

I prefer not having to manage this dependency inside an R function.

I'm already satisfied just having it documented. I think those that hit it could find it.

yihui commented 1 year ago

I'm already satisfied just having it documented.

Okay, I can certainly do that.

I'm on the Conda Forge R team.

Haha, didn't know that and good to know now!

pdimens commented 8 months ago

This doesn't seem to be resolved yet? Inside of the official mamba docker image, Mamba is trying to install tinytex as a dep for something else and I'm getting these error messages consistently:

error    libmamba response code: -1 error message: Invalid argument
critical libmamba failed to execute pre/post link script for r-tinytex

I have tried two approaches to including perl in the dockerfile:

  1. Installing perl via apt-get
    
    FROM mambaorg/micromamba

USER root

RUN apt-get update && apt-get install -y perl \ && rm -rf /var/lib/apt/lists/*

USER $MAMBA_USER

RUN micromamba install --yes --name base -c bioconda -c conda-forge \ falco \ fastp \ multiqc \ r-base \ r-dplyr \ r-dt \ r-flexdashboard \ r-ggplot2 \ r-knitr \ r-magrittr \ r-plotly \ r-rmarkdown \ r-tidyr \ r-viridislite


2. install via conda/mamba

FROM mambaorg/micromamba

RUN micromamba install --yes --name base -c bioconda -c conda-forge \ falco \ fastp \ multiqc \ r-base \ r-dplyr \ r-dt \ r-flexdashboard \ r-ggplot2 \ r-knitr \ r-magrittr \ r-plotly \ r-rmarkdown \ r-tidyr \ r-viridislite \ perl



The results are identical (critical failure) and I cannot proceed with environment creation
mfansler commented 8 months ago

@pdimens no, the problem is that the post-link script (which merely emits text) is crashing. Please add comments to this Issue - this is purely a Conda Forge thing and not something that needs to revive this thread. I will try to get to it this week.

mfansler commented 8 months ago

I've made the editorial decision to remove the notification emitted by the Conda Forge package regarding the need for Perl. There was both issue with the mechanism for emitting the message and confusion around interpretation of the message when it did work (users misinterpreted it as a warning/thought it meant Perl was not detected). In the end, seemed like more trouble than it was worth.