Subject: bug#52979: Modular texlive has problems finding fonts

From: Jelle Licht <[email-masked]>
Date: Mon, 03 Jan 2022 18:06:06 +0100

Jelle Licht <[email-masked]> writes:

> As discussed on #guix on IRC, several folks including myself ran into
> issues getting the following some-file.tex:
>
> --8<---------------cut here---------------start------------->8---
> \documentclass[11pt]{article}
> \begin{document}
> Hello friends
> \end{document}
> --8<---------------cut here---------------end--------------->8---
>
> ... to typeset with the following manifest.scm:
> --8<---------------cut here---------------start------------->8---
> (specifications->manifest
>  '("texlive-base"
>    "texlive-fonts-ec"
>    "texlive-amsfonts"
>    "texlive-fira"
>    "texlive-inconsolata"))
> --8<---------------cut here---------------end--------------->8---
>
> ... with command: 
> `guix shell --pure coreutils grep sed gawk -m manifest.scm -- pdflatex some-file
>
> Note that the monolithic texlive seems to work:
> `guix shell --pure coreutils grep sed gawk texlive -- pdflatex some-file'
>
> On IRC, rekado /w strace identified that texlive does not seem to be
> entering the subdirectory containing the font files, as it seems to be
> loading texlive-bin's texmf.cnf, instead of the one generated by
> `(@ (guix profiles) texlive-configuration)'.
The first part here is correct, the second part is not;

It seems texlive's kpathsea uses a heuristic to determine if a directory
is a 'leaf node', where it checks whether there are exactly 2 links in
there[1]; since symlinks do not count towards the link count, a directory
filled with only symlinks to other directories is seen as a leaf node,
and traversal subsequently ends there.

This heuristic is a performance optimisation, as simply doing stat calls
of everything in a directory is slow, according the the kpathsea
authors.

We can disable this optimisation by setting ST_NLINK_TRICK at compile
time. Alternatively, we could try to figure out a way in which our
directory-of-symlinks also contains at least one file.

[1]: That is, "." and ".."