XeLaTeX cannot generate a valid pdf

Hi @sez11a,

I’ve tried to compile your example file (I called it newmain.tex) on my machine and indeed it’s giving the same error you posted here.

❯ latexmk newmain.tex
Rc files read:
  .latexmkrc
Latexmk: This is Latexmk, John Collins, 7 Apr. 2024. Version 4.85.
Latexmk: applying rule 'lualatex'...
Rule 'lualatex':  Reasons for rerun
Changed files or newly in use/created:
  newmain.aux
  newmain.tex
Category 'changed_user':
  newmain.tex

------------
Run number 1 of rule 'lualatex'
------------
------------
Running 'lualatex  -recorder  "newmain.tex"'
------------
This is LuaTeX, Version 1.18.0 (TeX Live 2024/OpenMandriva)
 restricted system commands enabled.

kpathsea: Running mktexfmt lualatex.fmt
mktexfmt: mktexfmt is using the following fmtutil.cnf files (in precedence order):
mktexfmt:   /usr/share/texmf-dist/web2c/fmtutil.cnf
mktexfmt: mktexfmt is using the following fmtutil.cnf file for writing changes:
mktexfmt:   /home/silvano/.texlive2013/texmf-config/web2c/fmtutil.cnf
mktexfmt [INFO]: writing formats under /home/silvano/.texlive2013/texmf-var/web2c
mktexfmt [INFO]: --- remaking lualatex with luahbtex
mktexfmt: running `luahbtex -ini   -jobname=lualatex -progname=lualatex lualatex.ini' ...
This is LuaHBTeX, Version 1.18.0 (TeX Live 2024/OpenMandriva)  (INITEX)
 restricted system commands enabled.
(/usr/share/texmf-dist/tex/latex/tex-ini-files/lualatex.ini
(/usr/share/texmf-dist/tex/generic/tex-ini-files/luatexconfig.tex
(/usr/share/texmf-dist/tex/generic/config/pdftexconfig.tex))
(/usr/share/texmf-dist/tex/latex/base/latex.ltx
(/usr/share/texmf-dist/tex/latex/base/texsys.cfg)
./texsys.aux found


\@currdir set to: ./.


Assuming \openin and \input
have the same search path.


Defining UNIX/DOS style filename parser.

catcodes, registers, parameters,
LaTeX2e <2024-11-01> patch level 1
(/usr/share/texmf-dist/tex/latex/l3kernel/expl3.ltx
(/usr/share/texmf-dist/tex/latex/l3kernel/expl3-code.tex)) hacks,
document commands, templates, control, par, spacing, files, font encodings,
lengths, NFSS base, NFSS axes, NFSS tracing, NFSS declarative interface,
NFSS initialization,
====================================

Local config file fonttext.cfg used

====================================
(/usr/share/texmf-dist/tex/latex/base/fonttext.cfg
(/usr/share/texmf-dist/tex/latex/base/fonttext.ltx
=== Don't modify this file, use a .cfg file instead ===

(/usr/share/texmf-dist/tex/latex/base/omlenc.def)
(/usr/share/texmf-dist/tex/latex/base/omsenc.def)
(/usr/share/texmf-dist/tex/latex/base/ot1enc.def)
(/usr/share/texmf-dist/tex/latex/base/t1enc.def)
(/usr/share/texmf-dist/tex/latex/base/ts1enc.def)
(/usr/share/texmf-dist/tex/latex/base/tuenc.def)
(/usr/share/texmf-dist/tex/latex/base/tulmr.fd)
(/usr/share/texmf-dist/tex/latex/base/tulmss.fd)
(/usr/share/texmf-dist/tex/latex/base/tulmtt.fd)
(/usr/share/texmf-dist/tex/latex/lm/ts1lmr.fd)
(/usr/share/texmf-dist/tex/latex/base/t1cmr.fd)
(/usr/share/texmf-dist/tex/latex/base/ot1cmr.fd)
(/usr/share/texmf-dist/tex/latex/base/ts1cmr.fd)
(/usr/share/texmf-dist/tex/latex/base/t1cmss.fd)
(/usr/share/texmf-dist/tex/latex/base/t1cmtt.fd)
(/usr/share/texmf-dist/tex/latex/base/ot1cmss.fd)
(/usr/share/texmf-dist/tex/latex/base/ot1cmtt.fd)
(/usr/share/texmf-dist/tex/latex/base/ts1cmss.fd)
(/usr/share/texmf-dist/tex/latex/base/ts1cmtt.fd)))
====================================

Local config file fontmath.cfg used

====================================
(/usr/share/texmf-dist/tex/latex/base/fontmath.cfg
(/usr/share/texmf-dist/tex/latex/base/fontmath.ltx
=== Don't modify this file, use a .cfg file instead ===

(/usr/share/texmf-dist/tex/latex/base/omlcmm.fd)
(/usr/share/texmf-dist/tex/latex/base/omscmsy.fd)
(/usr/share/texmf-dist/tex/latex/base/omxcmex.fd)
(/usr/share/texmf-dist/tex/latex/base/ucmr.fd)))
====================================

Local config file preload.cfg used

=====================================
(/usr/share/texmf-dist/tex/latex/base/preload.cfg
(/usr/share/texmf-dist/tex/latex/base/preload.ltx)) page nos., x-ref,
environments, center, verbatim, math definitions, boxes, title, sectioning,
contents, floats, footnotes, index, bibliography, output,
 Unicode character data,
(/usr/share/texmf-dist/tex/generic/unicode-data/load-unicode-data.tex
load-unicode-data.tex v1.17 (2023-09-18)
Reading Unicode data
# UnicodeData-15.1.0.txt
# Modified 2023-09-18 08:45:00 GMT [JAW]
)
===========================================
Local configuration file hyphen.cfg used
===========================================
(/usr/share/texmf-dist/tex/generic/babel/hyphen.cfg
(/usr/share/texmf-dist/tex/generic/babel/luababel.def)
(/usr/share/texmf-dist/tex/generic/hyphen/hyphen.tex))
No file latex2e-first-aid-for-external-files.ltx.

))
Beginning to dump on file lualatex.fmt
 (format=lualatex 2025.7.13)
24160 strings using 434172 bytes
1071279 memory locations dumped; current usage is 204&506318
22808 multiletter control sequences
\font\nullfont=nullfont
\font\OMX/cmex/m/n/10=cmex10
\font\tenln=line10
\font\tenlnw=linew10
\font\tencirc=lcircle10
\font\tencircw=lcirclew10
\font\OT1/cmr/m/n/5=cmr5
\font\OT1/cmr/m/n/7=cmr7
\font\OT1/cmr/m/n/10=cmr10
\font\OML/cmm/m/it/5=cmmi5
\font\OML/cmm/m/it/7=cmmi7
\font\OML/cmm/m/it/10=cmmi10
\font\OMS/cmsy/m/n/5=cmsy5
\font\OMS/cmsy/m/n/7=cmsy7
\font\OMS/cmsy/m/n/10=cmsy10
14 preloaded fonts
warning  (pdf backend): no pages of output.
Transcript written on lualatex.log.
mktexfmt [INFO]: log file copied to: /home/silvano/.texlive2013/texmf-var/web2c/luahbtex/lualatex.log
mktexfmt [INFO]: /home/silvano/.texlive2013/texmf-var/web2c/luahbtex/lualatex.fmt installed.
mktexfmt [INFO]: disabled formats: 3
mktexfmt [INFO]: successfully rebuilt formats: 1
mktexfmt [INFO]: not selected formats: 53
mktexfmt [INFO]: total formats: 57
mktexfmt [INFO]: exiting with status 0

---! lualatex.fmt was written by luahbtex
(Fatal format file error; I'm stymied)Latexmk: No log file was found, neither the expected one, 'newmain.log', nor one in '.'.
Latexmk: fls file doesn't appear to have been made.
Latexmk: Getting log file 'newmain.log'
Latexmk: Couldn't read log file 'newmain.log':
  No such file or directory
Latexmk: Errors, so I did not complete making targets
Collected error summary (may duplicate other messages):
  lualatex: Run of rule 'lualatex' gave a non-zero error code
----------------------
This message may duplicate earlier message.
Latexmk: Failure in processing file 'newmain.tex':
   *LaTeX didn't generate the expected log file 'newmain.log'
----------------------

Latexmk: Sometimes, the -f option can be used to get latexmk
  to try to force complete processing.
  But normally, you will need to correct the file(s) that caused the
  error, and then rerun latexmk.
  In some cases, it is best to clean out generated files before rerunning
  latexmk after you've corrected the files.

Anyway, I’ve managed to compile with lualatex. I’ll describe in detail what I’ve done, hence this will be a very long post, sorry.

Running kpsewhich -var-value TEXMFCONFIG it confirms that texlive is configured to use the $HOME/.texlive2013/texmf-config, hence still a sudo fmtutil-sys --all or sudo fmtutil-sys --byfmt lualatex is not solving the problem. The fmtutil-user is not available on my system, but fmtutil --user can be used with the TEXMF{VAR,CONFIG} env variables correctly defined.

The $HOME/.texlive2013/ path is not set by my user configuration, hence it’s forced by system configuration. And indeed:

❯ cat /usr/share/texmf-dist/web2c/texmf.cnf | grep texlive2013
TEXMFVAR = $HOME/.texlive2013/texmf-var
TEXMFCONFIG = $HOME/.texlive2013/texmf-config

Anyway it shoud be forced to use the /usr/share/texmf-dist/web2c/fmtutil.cnf existing file.

At this point, I commented out the two lines that are defining the TEXMFVAR and TEXMFCONFIG env variables, removed the $HOME/.texlive2013 folder and tried to recompile the LaTeX file with latexmk newmain.tex, getting the same error.

❯ lualatex -interaction=nonstopmode newmain.tex
This is LuaTeX, Version 1.18.0 (TeX Live 2024/OpenMandriva)
 restricted system commands enabled.

kpathsea: Running mktexfmt lualatex.fmt
mktexfmt: mktexfmt is using the following fmtutil.cnf files (in precedence order):
mktexfmt:   /usr/share/texmf-dist/web2c/fmtutil.cnf
mktexfmt: mktexfmt is using the following fmtutil.cnf file for writing changes:
mktexfmt:   /usr/share/texmf-dist/web2c/fmtutil.cnf
/usr/bin/mktexfmt: mkdir(/web2c/) failed for tree /web2c: Permission denied at /usr/share/tlpkg/TeXLive/TLUtils.pm line 1207.
I can't find the format file `lualatex.fmt'!

The problem now is with permissions and I need to use sudo one time to let lualatex create the files in the system directory. Running sudo lualatex -interaction=nonstopmode newmain.tex will generate the format file.
The final error (—! lualatex.fmt was written by luahbtex (Fatal format file error; I’m stymied)) is fine because it tried to compile the file but it was not finding the just compiled fmt.
Anyway, compiling again without sudo it’s not working, hence I tried to reinstall the lualatex binary from the OM repos (sudo dnf reinstall texlive-latex.bin) and compile again (sudo lualatex newmain.tex) with no success.

With this texlive installation, when executed as user, it tries to write in the system directoy instead to use the pre-compiled formats, causing the permission errors. This seems to end up to restore the lines we previously commented out in the /usr/share/texmf-dist/web2c/texmf.cnf.
But, in place to restore the texmf.cnf, I tried to set the env variables only for the compilation command. This tells to latexmk (and to lualatex) to use a user defined directoy for its temporary files and configuration files, without creating conflicts.
(See how here I created a $HOME/.texlive folder, very similar to the $HOME/.texlive2013: just naming convention at this point).

❯ env TEXMFVAR=~/.texlive/texmf-var TEXMFCONFIG=~/.texlive/texmf-config latexmk newmain.tex

    Rc files read:
      .latexmkrc
    Latexmk: This is Latexmk, John Collins, 7 Apr. 2024. Version 4.85.
    Latexmk: applying rule 'lualatex'...
    Rule 'lualatex':  Reasons for rerun
    Changed files or newly in use/created:
      newmain.aux
      newmain.tex
    Category 'changed_user':
      newmain.tex

    ------------
    Run number 1 of rule 'lualatex'
    ------------
    ------------
    Running 'lualatex  -recorder  "newmain.tex"'
    ------------

    kpathsea: Running mktexfmt lualatex.fmt
    mktexfmt: mktexfmt is using the following fmtutil.cnf files (in precedence order):
    mktexfmt:   /usr/share/texmf-dist/web2c/fmtutil.cnf
    mktexfmt: mktexfmt is using the following fmtutil.cnf file for writing changes:
    mktexfmt:   /home/silvano/.texlive/texmf-config/web2c/fmtutil.cnf
    mktexfmt [INFO]: writing formats under /home/silvano/.texlive/texmf-var/web2c
    mktexfmt [INFO]: --- remaking lualatex with luahbtex
    mktexfmt: running `luahbtex -ini   -jobname=lualatex -progname=lualatex lualatex.ini' ...
    This is LuaHBTeX, Version 1.18.0 (TeX Live 2024/OpenMandriva)  (INITEX)
     restricted system commands enabled.
    (/usr/share/texmf-dist/tex/latex/tex-ini-files/lualatex.ini
    (/usr/share/texmf-dist/tex/generic/tex-ini-files/luatexconfig.tex
    (/usr/share/texmf-dist/tex/generic/config/pdftexconfig.tex))
    (/usr/share/texmf-dist/tex/latex/base/latex.ltx
    (/usr/share/texmf-dist/tex/latex/base/texsys.cfg)
    ./texsys.aux found


    \@currdir set to: ./.


    Assuming \openin and \input
    have the same search path.


    Defining UNIX/DOS style filename parser.

    catcodes, registers, parameters,
    LaTeX2e <2024-11-01> patch level 1
    (/usr/share/texmf-dist/tex/latex/l3kernel/expl3.ltx
    (/usr/share/texmf-dist/tex/latex/l3kernel/expl3-code.tex)) hacks,
    document commands, templates, control, par, spacing, files, font encodings,
    lengths, NFSS base, NFSS axes, NFSS tracing, NFSS declarative interface,
    NFSS initialization,
    ====================================

    Local config file fonttext.cfg used

    ====================================
    (/usr/share/texmf-dist/tex/latex/base/fonttext.cfg
    (/usr/share/texmf-dist/tex/latex/base/fonttext.ltx
    === Don't modify this file, use a .cfg file instead ===

    (/usr/share/texmf-dist/tex/latex/base/omlenc.def)
    (/usr/share/texmf-dist/tex/latex/base/omsenc.def)
    (/usr/share/texmf-dist/tex/latex/base/ot1enc.def)
    (/usr/share/texmf-dist/tex/latex/base/t1enc.def)
    (/usr/share/texmf-dist/tex/latex/base/ts1enc.def)
    (/usr/share/texmf-dist/tex/latex/base/tuenc.def)
    (/usr/share/texmf-dist/tex/latex/base/tulmr.fd)
    (/usr/share/texmf-dist/tex/latex/base/tulmss.fd)
    (/usr/share/texmf-dist/tex/latex/base/tulmtt.fd)
    (/usr/share/texmf-dist/tex/latex/lm/ts1lmr.fd)
    (/usr/share/texmf-dist/tex/latex/base/t1cmr.fd)
    (/usr/share/texmf-dist/tex/latex/base/ot1cmr.fd)
    (/usr/share/texmf-dist/tex/latex/base/ts1cmr.fd)
    (/usr/share/texmf-dist/tex/latex/base/t1cmss.fd)
    (/usr/share/texmf-dist/tex/latex/base/t1cmtt.fd)
    (/usr/share/texmf-dist/tex/latex/base/ot1cmss.fd)
    (/usr/share/texmf-dist/tex/latex/base/ot1cmtt.fd)
    (/usr/share/texmf-dist/tex/latex/base/ts1cmss.fd)
    (/usr/share/texmf-dist/tex/latex/base/ts1cmtt.fd)))
    ====================================

    Local config file fontmath.cfg used

    ====================================
    (/usr/share/texmf-dist/tex/latex/base/fontmath.cfg
    (/usr/share/texmf-dist/tex/latex/base/fontmath.ltx
    === Don't modify this file, use a .cfg file instead ===

    (/usr/share/texmf-dist/tex/latex/base/omlcmm.fd)
    (/usr/share/texmf-dist/tex/latex/base/omscmsy.fd)
    (/usr/share/texmf-dist/tex/latex/base/omxcmex.fd)
    (/usr/share/texmf-dist/tex/latex/base/ucmr.fd)))
    ====================================

    Local config file preload.cfg used

    =====================================
    (/usr/share/texmf-dist/tex/latex/base/preload.cfg
    (/usr/share/texmf-dist/tex/latex/base/preload.ltx)) page nos., x-ref,
    environments, center, verbatim, math definitions, boxes, title, sectioning,
    contents, floats, footnotes, index, bibliography, output,
     Unicode character data,
    (/usr/share/texmf-dist/tex/generic/unicode-data/load-unicode-data.tex
    load-unicode-data.tex v1.17 (2023-09-18)
    Reading Unicode data
    # UnicodeData-15.1.0.txt
    # Modified 2023-09-18 08:45:00 GMT [JAW]
    )
    ===========================================
    Local configuration file hyphen.cfg used
    ===========================================
    (/usr/share/texmf-dist/tex/generic/babel/hyphen.cfg
    (/usr/share/texmf-dist/tex/generic/babel/luababel.def)
    (/usr/share/texmf-dist/tex/generic/hyphen/hyphen.tex))
    No file latex2e-first-aid-for-external-files.ltx.

    ))
    Beginning to dump on file lualatex.fmt
     (format=lualatex 2025.7.14)
    24160 strings using 434172 bytes
    1071209 memory locations dumped; current usage is 204&506283
    22808 multiletter control sequences
    \font\nullfont=nullfont
    \font\OMX/cmex/m/n/10=cmex10
    \font\tenln=line10
    \font\tenlnw=linew10
    \font\tencirc=lcircle10
    \font\tencircw=lcirclew10
    \font\OT1/cmr/m/n/5=cmr5
    \font\OT1/cmr/m/n/7=cmr7
    \font\OT1/cmr/m/n/10=cmr10
    \font\OML/cmm/m/it/5=cmmi5
    \font\OML/cmm/m/it/7=cmmi7
    \font\OML/cmm/m/it/10=cmmi10
    \font\OMS/cmsy/m/n/5=cmsy5
    \font\OMS/cmsy/m/n/7=cmsy7
    \font\OMS/cmsy/m/n/10=cmsy10
    14 preloaded fonts
    warning  (pdf backend): no pages of output.
    Transcript written on lualatex.log.
    mktexfmt [INFO]: log file copied to: /home/silvano/.texlive/texmf-var/web2c/luahbtex/lualatex.log
    mktexfmt [INFO]: /home/silvano/.texlive/texmf-var/web2c/luahbtex/lualatex.fmt installed.
    mktexfmt [INFO]: disabled formats: 3
    mktexfmt [INFO]: successfully rebuilt formats: 1
    mktexfmt [INFO]: not selected formats: 53
    mktexfmt [INFO]: total formats: 57
    mktexfmt [INFO]:
    *************************************************************
    *                                                           *
    * WARNING: you are switching to fmtutil's per-user formats. *
    *         Please read the following warnings!               *
    *                                                           *
    *************************************************************

    You have run fmtutil-user (as opposed to fmtutil-sys) for the first time;
    this has created format files which are local to your personal account.

    From now on, any changes in system formats will *not* be automatically
    reflected in your files; furthermore, running fmtutil-sys will no longer
    have any effect for you.

    As a consequence, you yourself have to rerun fmtutil-user after any
    change in the system directories. For example, when one of the LaTeX or
    other format source files changes, which happens frequently.
    See https://tug.org/texlive/scripts-sys-user.html for details.

    If you want to undo this, remove the files mentioned above.

    Run mktexfmt --help for full documentation of fmtutil.
    mktexfmt [INFO]: exiting with status 0
    This is LuaTeX, Version 1.18.0 (TeX Live 2024/OpenMandriva)
     restricted system commands enabled.

    ---! lualatex.fmt was written by luahbtex
    (Fatal format file error; I'm stymied)Latexmk: Getting log file 'newmain.log'
    Latexmk: Errors, so I did not complete making targets
    Collected error summary (may duplicate other messages):
      lualatex: Run of rule 'lualatex' gave a non-zero error code

    Latexmk: No log file was found, neither the expected one, 'newmain.log', nor one in '.'.
    Latexmk: fls file doesn't appear to have been made.
    Latexmk: Couldn't read log file 'newmain.log':
      No such file or directory
    ----------------------
    This message may duplicate earlier message.
    Latexmk: Failure in processing file 'newmain.tex':
       *LaTeX didn't generate the expected log file 'newmain.log'
    ----------------------
    Latexmk: Sometimes, the -f option can be used to get latexmk
      to try to force complete processing.
      But normally, you will need to correct the file(s) that caused the
      error, and then rerun latexmk.
      In some cases, it is best to clean out generated files before rerunning
      latexmk after you've corrected the files.

The output is showing mktexfmt that is writing the fmt in the user directory (/home/silvano/.texlive/texmf-var/web2c) without permission errors. The fatal format file error is here because the fmt is created in the same compilation command.
At this point, a second execution of the same command should compile the document, but it gives the same issue we’re fighting from the beginning (we’re basically using the same configuration of the first install).

Here below there is how I modified the .latexmkrc to force lualatex to use the just generated fmt files (take care tu use absolute path and not the ~):

    7    + $lualatex = 'lualatex --fmt="/home/silvano/.texlive/texmf-var/web2c/lualatex.fmt" %O %S';
    8      $pdf_mode = 4;
    9      $dvi_mode = '0';
    10     $pdf_previewer = 'start okular'

Now, with the latexmk configuration explicitly pointing to the correct format file, I run the compilation command. This time, lualatex will have no choice but to use the format file we created.

❯ latexmk newmain.tex

    [CUT]
    This is LuaTeX, Version 1.18.0 (TeX Live 2024/OpenMandriva)
     restricted system commands enabled.
    I can't find the format file `/home/silvano/.texlive/texmf-var/web2c/lualatex.fmt'!
    Latexmk: Getting log file 'newmain.log'
    Latexmk: Errors, so I did not complete making targets
    Collected error summary (may duplicate other messages):
      lualatex: Run of rule 'lualatex' gave a non-zero error code

Okay, the error is still the same. This means that the problem is not just finding the file, but that lualatex insists on creating it every time, ignoring the existing one.
Let’s try to force format creation with the absolute path. This command will tell lualatex to create the format file exactly where we expect it to be.

In order to avoid any permissions of path problems, I perform the format creation inside the folder that must contain the file:

❯ cd /home/silvano/.texlive/texmf-var/web2c && lualatex -ini -jobname=lualatex -progname=lualatex lualatex.ini

   This is LuaTeX, Version 1.18.0 (TeX Live 2024/OpenMandriva)  (INITEX)
    restricted system commands enabled.

   [CUT]

   warning  (pdf backend): no pages of output.
   Transcript written on lualatex.log.

Finally. The format file has been successfully created. Now that the lualatex.fmt file exists in the user directory, and the compilation should run smoothly.
I go back to the original directory and re-run latexmk. This time, it will use the format we just created.

❯ cd /home/silvano/Documents/latextest/newmain && latexmk newmain.tex

   Rc files read:
     .latexmkrc
   Latexmk: This is Latexmk, John Collins, 7 Apr. 2024. Version 4.85.
   Latexmk: applying rule 'lualatex'...
   Rule 'lualatex':  Reasons for rerun
   Changed files or newly in use/created:
     newmain.aux
     newmain.tex
   Category 'changed_user':
     newmain.tex

   ------------
   Run number 1 of rule 'lualatex'
   ------------
   ------------
   Running 'lualatex --fmt="/home/silvano/.texlive/texmf-var/web2c/lualatex.fmt"  -recorder  "newmain.tex"'
   ------------
   This is LuaTeX, Version 1.18.0 (TeX Live 2024/OpenMandriva)
    restricted system commands enabled.
   (./newmain.tex
   LaTeX2e <2024-11-01> patch level 1
   L3 programming layer <2024-09-10>


   luaotfload | load : FATAL ERROR
   luaotfload | load :   × Failed to load "luaotfload" module "database".
   luaotfload | load :   × Error message:
   luaotfload | load :     × "...texmf-dist/tex/luatex/luaotfload/luaotfload-database.lua:203: module 'lua-uni-case' not found:".
   luaotfload | load :     × "no field package.preload['lua-uni-case']".
   luaotfload | load :     × "[kpse lua searcher] file not found: 'lua-uni-case'".

   stack traceback:
     /usr/share/texmf-dist/tex/luatex/luaotfload/luaotfload.lua:200: in upvalue 'loadmodule'
     /usr/share/texmf-dist/tex/luatex/luaotfload/luaotfload.lua:275: in local 'initialize'
     /usr/share/texmf-dist/tex/luatex/luaotfload/luaotfload.lua:330: in field 'main'
     [\directlua]:1: in main chunk

   Latexmk: Sometimes, the -f option can be used to get latexmk
     to try to force complete processing.
     But normally, you will need to correct the file(s) that caused the
     error, and then rerun latexmk.
     In some cases, it is best to clean out generated files before rerunning
     latexmk after you've corrected the files.
   Latexmk: Getting log file 'newmain.log'
   Latexmk: Examining 'newmain.fls'
   Latexmk: Examining 'newmain.log'
   Latexmk: Errors, so I did not complete making targets
   Collected error summary (may duplicate other messages):
     lualatex: Command for 'lualatex' gave return code 255
         Refer to 'newmain.log' and/or above output for details

This is a different problem. It means that lualatex is missing a fundamental Lua module, lua-uni-case.
This is not a configuration problem, but a problem of missing dependencies in the installation of TeX Live.
I search the package that provides the module:

❯ dnf provides '*/lua-uni-case.lua'
Last metadata expiration check: 0:37:26 ago on lun 14 lug 2025, 00:23:49.
texlive-lua-uni-algos-62204-1.noarch : Unicode algorithms for LuaTeX
Repo        : rolling-x86_64
Matched from:
Filename    : /usr/share/texmf-dist/tex/luatex/lua-uni-algos/lua-uni-case.lua

Indeed, in the system the package is not installed:

❯ rpm -qa | grep texlive-lua
texlive-lua-alt-getopt-56414-1.noarch
texlive-luatex.bin-20240312-10.x86_64
texlive-luatex-66967-1.noarch
texlive-luaxml-72858-1.noarch
texlive-luatextra-20747-2.noarch
texlive-luatexko-68243-1.noarch
texlive-luatexja-72546-1.noarch
texlive-luatexbase-52663-1.noarch
texlive-luasseq-65511-1.noarch
texlive-luaotfload-70234-1.noarch
texlive-luamplib-73137-1.noarch
texlive-lualibs-67994-1.noarch
texlive-lualatex-math-61464-1.noarch
texlive-lualatex-doc-de-30474-1.noarch
texlive-lualatex-doc-30473-1.noarch
texlive-luaintro-35490-1.noarch
texlive-luainputenc-20491-2.noarch
texlive-luaindex-25882-2.noarch
texlive-luacode-25193-2.noarch
texlive-luabidi-68432-1.noarch
texlive-luabibentry-55777-2.noarch
texlive-lua2dox-0.2-13.noarch
texlive-lua-visual-debug-65464-1.noarch
texlive-lua-check-hyphen-47527-2.noarch

So, I install the package:

❯ sudo dnf in texlive-lua-uni-algos

Now I can run again the compilation command:

latexmk -C && latexmk newmain.tex

    Rc files read:
      .latexmkrc
    Latexmk: This is Latexmk, John Collins, 7 Apr. 2024. Version 4.85.
    Latexmk: Doing main (small) clean up for 'newmain.tex'

    Rc files read:
      .latexmkrc
    Latexmk: This is Latexmk, John Collins, 7 Apr. 2024. Version 4.85.
    No existing .aux file, so I'll make a simple one, and require run of *latex.
    Latexmk: applying rule 'lualatex'...
    Rule 'lualatex':  Reasons for rerun
    Category 'other':
      Rerun of 'lualatex' forced or previously required:
        Reason or flag: 'Initial setup'

    ------------
    Run number 1 of rule 'lualatex'
    ------------
    ------------
    Running 'lualatex --fmt="/home/silvano/.texlive/texmf-var/web2c/lualatex.fmt"  -recorder  "newmain.tex"'
    ------------
    This is LuaTeX, Version 1.18.0 (TeX Live 2024/OpenMandriva)
     restricted system commands enabled.
    (./newmain.tex
    LaTeX2e <2024-11-01> patch level 1
    L3 programming layer <2024-09-10>
     (/usr/share/texmf-dist/tex/latex/base/article.cls
    Document Class: article 2024/06/29 v1.4n Standard LaTeX document class
    (/usr/share/texmf-dist/tex/latex/base/size11.clo
    luaotfload | db : Font names database not found, generating new one.
    luaotfload | db : This can take several minutes; please be patient.))
    (/usr/share/texmf-dist/tex/latex/microtype/microtype.sty
    (/usr/share/texmf-dist/tex/latex/graphics/keyval.sty)
    (/usr/share/texmf-dist/tex/latex/etoolbox/etoolbox.sty)
    (/usr/share/texmf-dist/tex/latex/microtype/microtype-luatex.def)
    (/usr/share/texmf-dist/tex/latex/microtype/microtype.cfg))
    (/usr/share/texmf-dist/tex/latex/graphics/graphicx.sty
    (/usr/share/texmf-dist/tex/latex/graphics/graphics.sty
    (/usr/share/texmf-dist/tex/latex/graphics/trig.sty)
    (/usr/share/texmf-dist/tex/latex/graphics-cfg/graphics.cfg)

    ! LaTeX Error: File `luatex.def' not found.

    Type X to quit or <RETURN> to proceed,
    or enter new name. (Default extension: def)

    Enter file name:
    ! Emergency stop.
    <read *>

    l.107 ...ned{ver@\Gin@driver}{\input{\Gin@driver}}{}

     381 words of node memory still in use:
       2 hlist, 1 rule, 1 dir, 3 kern, 1 glyph, 3 attribute, 48 glue_spec, 3 attrib
    ute_list, 3 if_stack, 1 write nodes
       avail lists: 2:6,3:2,4:1,5:1,7:2,9:3
    !  ==> Fatal error occurred, no output PDF file produced!
    Transcript written on newmain.log.
    Latexmk: Missing input file 'luatex.def' (or dependence on it) from following:
      ! LaTeX Error: File `luatex.def' not found.
    Latexmk: Sometimes, the -f option can be used to get latexmk
      to try to force complete processing.
      But normally, you will need to correct the file(s) that caused the
      error, and then rerun latexmk.
      In some cases, it is best to clean out generated files before rerunning
      latexmk after you've corrected the files.
    Latexmk: Getting log file 'newmain.log'
    Latexmk: Examining 'newmain.fls'
    Latexmk: Examining 'newmain.log'
    Latexmk: Errors, so I did not complete making targets
    Collected error summary (may duplicate other messages):
      lualatex: Command for 'lualatex' gave return code 1
          Refer to 'newmain.log' and/or above output for details

Ok, another missing file: luatex.def. This is a graphics driver definition file for lualatex.

❯ dnf provides '*/luatex.def'
Last metadata expiration check: 0:45:35 ago on lun 14 lug 2025, 00:23:49.
texlive-graphics-def-70970-1.noarch : Colour and graphics option files
Repo        : rolling-x86_64
Matched from:
Filename    : /usr/share/texmf-dist/tex/latex/graphics-def/luatex.def

I need to install the texlive-graphics-def package:

❯ rpm -qa | grep "texlive-graphics"
texlive-graphics-71408-1.noarch
texlive-graphics-cfg-41448-1.noarch
texlive-graphics-pln-71575-1.noarch

❯ sudo dnf in texlive-graphics-def

At this point I can compile again the document with latexmk -C && latexmk newmain.tex and comes out that there is another issue.
Now the problem is no longer the TeX configuration, but the fonts. The font “Nimbus Mono” cannot be found.
The required font names are URW Bookman, URW Gothic, Nimbus Mono and are provided by the urw-fonts package that it’s already installed in the system:

❯ rpm -qa | grep urw-fonts
urw-fonts-2020.09.10-2.noarch

I tried to update the fonts cache with sudo fc-cache -f -v and compile again: the Nimbus font it’s still not found.
Ok, the problem could be the luaotfload font database (the engine that fontspec uses to find fonts) is out of date. I need to force its rebuilding.
This is done with the luaotfload-tool command. This command analyzes all the fonts that TeX can see and creates a database of them.
I run the command to update the luaotfload font database (luaotfload-tool --update --force), but this is not helping: even after updating the database, the font is not found.
This suggests that the font name “Nimbus Mono” in the TeX document does not exactly match the font name in the system.
Turns out that the font name is different, in the system it’s called “Nimbus Mono PS” (as the output of fc-list | grep -i "nimbus mono" confirms):

At this point, I change the font name in the newmain.tex file:

  22   - \setmonofont{Nimbus Mono}
  22   + \setmonofont{Nimbus Mono PS}

Now that the font name has been corrected, the compilation should finally work.

 ❯ latexmk -C && latexmk newmain.tex

    [CUT]

    Output written on newmain.pdf (1 page, 16282 bytes).
    Transcript written on newmain.log.
    Latexmk: Getting log file 'newmain.log'
    Latexmk: Examining 'newmain.fls'
    Latexmk: Examining 'newmain.log'
    Latexmk: Log file says output to 'newmain.pdf'
    Latexmk: All targets (newmain.pdf) are up-to-date

Et voilà!!! The compilation was successful and the newmain.pdf file was created.

I have not tried to restore the original configuration and try to simply install the missing dependencies (texlive-lua-uni-algos and texlive-graphics-def) and forcing the local generation of the format file (cd /home/silvano/.texlive/texmf-var/web2c && lualatex -ini -jobname=lualatex -progname=lualatex lualatex.ini), if you try in a VM with a fresh install let me know.
newmain.pdf (15,9 KB)

1 Like