Skip to content

LuaLaTeX luaotfload fails to find a font #180639

Closed

Description

@charmoniumQ

Describe the bug

lualatex fails because it can't find a character in the default font, because the default font is null, because luaotfload fails to load fontloader module basics-gen, because there is no writable system cache.

Steps To Reproduce

Steps to reproduce the behavior:

  1. Write test1.tex: Hello world \bye.
  2. Write test2.tex: \documentclass{article} \begin{document} Hello world \end{document}
  3. Write a flake.nix:
{
  outputs = { self, nixpkgs }:
  let
    system = "x86_64-linux";
    pkgs = nixpkgs.legacyPackages.${system};
  in
  {
    packages.${system}.default = pkgs.stdenvNoCC.mkDerivation {
        name = "test";
        src = ./.;
        buildInputs = [
            (pkgs.texlive.combine {
                inherit (pkgs.texlive) scheme-basic collection-luatex;
            })
        ];
        buildPhase = ''
            mkdir $out
            # Test raw LuaTeX (succeeds)
            luatex   -interaction=nonstopmode -output-format=pdf -output-directory=$out ./test1.tex;

            # Test LuaLaTeX (fails)
            lualatex -interaction=nonstopmode -output-format=pdf -output-directory=$out ./test2.tex;
        '';
        phases = [ "unpackPhase" "buildPhase" ];
    };
  };
}

4, Run nix build -L

Observe that raw LuaTeX document compiles, but the LuaLaTeX document fails to compile:

test> luaotfload | load : FATAL ERROR
test> luaotfload | load :   × Failed to load "fontloader" module "basics-gen".
test> luaotfload | load :   × Error message:
test> luaotfload | load :     × "...21/share/texmf/tex/luatex/luaotfload/luaotfload-init.lua:301: system : no writeable cache path, quiting".
test> stack traceback:
test>   ...ed-2021/share/texmf/tex/luatex/luaotfload/luaotfload.lua:200: in local 'load_fontloader_module'
test>   ...21/share/texmf/tex/luatex/luaotfload/luaotfload-init.lua:303: in upvalue 'init_main'
test>   ...21/share/texmf/tex/luatex/luaotfload/luaotfload-init.lua:590: in function 'luaotfload-init.lua'
test>   ...ed-2021/share/texmf/tex/luatex/luaotfload/luaotfload.lua:322: in field 'main'
test>   [\directlua]:1: in main chunk
test> ...21/share/texmf/tex/luatex/luaotfload/luaotfload-init.lua:301: system : no wr
test> iteable cache path, quiting
test> stack traceback:
test>   [C]: in function 'error'
test>   ...21/share/texmf/tex/luatex/luaotfload/luaotfload-init.lua:301: in function '
test> os.exit'
test>   ...ed-2021/share/texmf/tex/luatex/luaotfload/luaotfload.lua:203: in local 'loa
test> d_fontloader_module'
test>   ...21/share/texmf/tex/luatex/luaotfload/luaotfload-init.lua:303: in upvalue 'i
test> nit_main'
test>   ...21/share/texmf/tex/luatex/luaotfload/luaotfload-init.lua:590: in function '
test> luaotfload-init.lua'
test>   ...ed-2021/share/texmf/tex/luatex/luaotfload/luaotfload.lua:322: in field 'mai
test> n'
test>   [\directlua]:1: in main chunk.
test> <everyjob> ...ring \\def\string \\encodingdefault{OT1}')end }
test>                                                   \let \f@encoding \encoding...
<snip>
test> Missing character: There is no H (U+0048) in font nullfont!
test> Missing character: There is no e (U+0065) in font nullfont!
test> Missing character: There is no l (U+006C) in font nullfont!
test> Missing character: There is no l (U+006C) in font nullfont!
test> Missing character: There is no o (U+006F) in font nullfont!
test> Missing character: There is no , (U+002C) in font nullfont!
test> Missing character: There is no w (U+0077) in font nullfont!
test> Missing character: There is no o (U+006F) in font nullfont!
test> Missing character: There is no r (U+0072) in font nullfont!
test> Missing character: There is no l (U+006C) in font nullfont!
test> Missing character: There is no d (U+0064) in font nullfont!
test> Missing character: There is no ! (U+0021) in font nullfont!
test> Missing character: There is no 1 (U+0031) in font nullfont!

Notify maintainers

@veprbl

Metadata

[user@system:~]$ nix-shell -p nix-info --run "nix-info -m"
 - system: `"x86_64-linux"`
 - host os: `Linux 5.13.0-46-generic, Ubuntu, 20.04.4 LTS (Focal Fossa), nobuild`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.9.1`
 - channels(root): `"nixpkgs"`
 - channels(sam): `"home-manager, nixpkgs-22.11pre384163.18de53ca965"`
 - nixpkgs: `/home/sam/.nix-defexpr/channels/nixpkgs`

Activity

  1. veprbl commented on Jul 8, 2022

    @veprbl
    Member

    Try adding export HOME=$(mktemp -d).

    I'm not sure if it would be feasible to have those caches pre-populated. /cc @xworld21

  2. added
    6.topic: TeXIssues regarding texlive and TeX in general
    on Jul 8, 2022
  3. charmoniumQ commented on Jul 8, 2022

    @charmoniumQ
    ContributorAuthor

    That works; thanks!

  4. DarkaMaul commented on Oct 18, 2023

    @DarkaMaul

    The error is still present today but the fix suggested here still works.

  5. xworld21 commented on Oct 19, 2023

    @xworld21
    Contributor

    I suppose we can reopen the issue as a feature request to pre-populate the font cache of luaotfload. I might discover it is not feasible, but at least we will know.

  6. dpaetzel commented on Jan 18, 2024

    @dpaetzel
    Contributor

    For anyone still having this problem: My workaround is to—whenever I run into this issue (in my case I notice this when the PDF output is once more full of many weird arcane symbols)—simply run

    rm -rf ~/.texlive2022/texmf-var/luatex-cache/
    

    and then it works again for a few days/weeks (presumably until I upgrade my LaTeX distribution or something like that; not 100% sure what the trigger is).

    (Courtesy of this stackoverflow post.)

  7. charmoniumQ commented on Jan 18, 2024

    @charmoniumQ
    ContributorAuthor

    I suppose we can reopen the issue as a feature request to pre-populate the font cache of luaotfload. I might discover it is not feasible, but at least we will know.

    Did you discover anything? Would it suffice to compile a document which uses every font the user may be interested in, which might cause luatex to load those fonts into its cache?

  8. nixos-discourse commented on Nov 27, 2024

    @nixos-discourse

    This issue has been mentioned on NixOS Discourse. There might be relevant details there:

    https://discourse.nixos.org/t/lualatex-doesnt-work-in-development-since-update-to-texlive2024/56668/2

  9. bmrips commented on Apr 30, 2025

    @bmrips
    Contributor

    Try adding export HOME=$(mktemp -d).

    I'm not sure if it would be feasible to have those caches pre-populated. /cc @xworld21

    I figured out that also export TEXMFVAR=$(mktemp -d) solves this issue. Not having to override HOME is especially helpful for devshells.

  10. mskiptr commented on Sep 6, 2025

    @mskiptr

    Seems quite similar to https://gitlab.alpinelinux.org/alpine/aports/-/issues/16667. If nixpkgs uses LuaLaTeX ≥ 7606, then this issue has most likely been resolved upstream and the workarounds are no longer needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    0.kind: bugSomething is broken6.topic: TeXIssues regarding texlive and TeX in general

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions