1

I'm currently working on getting TeXLive usable in Linux Flatpaks, however LuaLaTeX "silently" fails and I have no idea what might be wrong or where to start. The output and symptoms are not unlike Lualatex produces no output (MiKTeX), however I'm neither on Windows with UCS/ANSI encoding, nor are my files or $HOME in a non-ASCII path, nor am I using MikTeX.

I'm reusing the mwe from the linked question:

Compiling

abc \bye

with luatex works but if I load the otf package:

\input luaotfload.sty
abc \bye

I get:

$ luatex mwe.tex 
This is LuaTeX, Version 1.12.0 (TeX Live 2020) 
 restricted system commands enabled.
(./mwe.tex
(/usr/lib/sdk/texlive/texmf-dist/tex/luatex/luaotfload/luaotfload.sty
(/usr/lib/sdk/texlive/texmf-dist/tex/latex/base/ltluatex.tex)

It may be notable that the last line of the output/log is missing a newline which may indicate a crash of the engine(?).

Furthermore, running luaotfload-tool -u even with highest verbosity doesn't give any output at all. However, for what it's worth, ConTeXt MkIV (i.e. using LuaTeX as backend) works fine.

My first assumption was that the Flatpak being based on the DVD release of TeXLive 2020 without any updates since (including two minor releases of luaotfload) was too old. I'm currently working on being able to use more recent daily-snapshots of TeXLive in Flatpak (https://github.com/flathub/org.freedesktop.Sdk.Extension.texlive/pull/28), however this didn't change any of the above behavior (I've confirmed that I'm indeed running luaotfload 3.14 in the Flatpak).

Steps to reproduce:

  1. Configure the flathub remote and your distro to have flatpaks in your path, then install TeXLive:

    $ flatpak install org.freedesktop.Sdk.Extension.texlive
    
  2. Run a shell within the Sandbox and put the TeXLive SDK into the PATH:

    $ flatpak run --command=/usr/bin/sh --devel org.freedesktop.Sdk
    [ org.freedesktop.Sdk ~ ]$ source /usr/lib/sdk/texlive/enable.sh 
    
  3. Create a MWE and build:

    [ org.freedesktop.Sdk ~ ]$ cat > mwe.tex
    \input luaotfload.sty
    abc \bye
    [ org.freedesktop.Sdk ~ ]$ luatex mwe.tex
    
2
3

I was facing the same problem recently when trying to build TeX documents with Nix. After some debugging I found out that the fundamental problem is that TEXMFCACHE is not writable. Looking into texmf.cnf we find the default values in

[📦 org.freedesktop.Sdk ~]$ cat /usr/lib/sdk/texlive/texmf-dist/web2c/texmf.cnf  | grep -e '^TEXMFVAR' -e '^TEXMFSYSVAR' -e '^TEXMFCACHE'
TEXMFSYSVAR = $TEXMFROOT/texmf-var
TEXMFVAR = ~/.texlive2020/texmf-var
TEXMFCACHE = $TEXMFSYSVAR;$TEXMFVAR

For Flatpak, some are being overriden by the ./install-tl -portable option as part of the packaging process of the Flatpak:

[📦 org.freedesktop.Sdk ~]$ cat /usr/lib/sdk/texlive/texmf.cnf | grep -e '^[^%]'
TEXMFLOCAL = $SELFAUTOPARENT/texmf-local
TEXMFHOME = $TEXMFLOCAL
TEXMFVAR = $TEXMFSYSVAR
TEXMFCONFIG = $TEXMFSYSCONFIG
ASYMPTOTE_HOME = $TEXMFCONFIG/asymptote

So originally TEXMFCACHE is defined in terms of TEXMFSYSVAR and TEXMFVAR. The first one, TEXMFSYSVAR, is usually not writable on most systems, whereas the latter, TEXMFVAR, is assumed to always be writable. This assumption of course fails if everything is mounted as a read-only overlay of the system, like on Nix.

In the Flatpak the issue is not the same, but related, as TEXMFVAR and thus also TEXMFCACHE point to TEXMFSYSVAR only (due to the -portable option). As this directory is read-only, this fails as well.

Luckily you can override the values in texmf.cnf by just setting environment variables of the same name. So for instance we could use

$ flatpak run --env=TEXMFVAR=/tmp --command=/usr/bin/sh --devel org.freedesktop.Sdk

Here I chose TEXMFVAR=/tmp, but any other directory that is guaranteed to writable would work as well, e.g. TEXMFVAR=/run/user/$(id -u). For Flatpaks it would be reasonable to set them to their (not the hosts!) $XDG_CACHE_HOME value, e.g. ~/.var/app/com.visualstudio.code/cache/texmf-var when using the SDK within VS Code.

Merely setting TEXMFCACHE would solve the luaotfload problem, as well. However, if you need to generate tfm or pk fonts on the fly you will hit a wall again, because this needs write-access to TEXMFVAR.

7
  • What a coincidence, and I thought I was the odd one trying to use TeX in Flatpaks :) I've run flatpak run --env=TEXMFVAR=$XDG_CACHE_HOME/texmf-var --command=/usr/bin/sh --devel org.freedesktop.Sdk and this works (as XDG_CACHE_HOME is set properly in Flatpak). I see that the silent errors are being handled upstream, that's nice!
    – ljrk
    Aug 23 '20 at 15:08
  • However I wanted to now build a Flatpak that has the desired behavior from the start, but now I cannot reproduce the bug anymore. Ever since I ran run with --env the problem doesn't occur anymore and the cache is built in $HOME/.var/app/com.visualstudio.code/cache/texmf-var/ and I've got no idea why this happens. I've removed any overrides/configs/caches that I can think of; but that's no question for TeX.SX I guess :)
    – ljrk
    Aug 23 '20 at 15:09
  • Oh found the error in my thoughts: The actual texmf.cnf isn't in /usr/lib/sdk/texlive/texmf-dist/web2c/texmf.cnf but in /usr/lib/sdk/texlive/texmf.cnf, I'll propose an edit to this answer. I hope I can provide a fixed flatpak soon-ish.
    – ljrk
    Aug 23 '20 at 17:49
  • @ljrk /usr/lib/sdk/texlive/texmf.cnf is the system-specific texmf.cnf and should actually be empty. It is meant to put your overrides for the default values into this file. The file /usr/lib/sdk/texlive/texmf-dist/web2c/texmf.cnf is the one that contains the values that were specified during installation. Aug 23 '20 at 22:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.