I am trying to generate and compile LuaLaTeX programmatically in order to generate a report for some numerical analysis program because the end-users cannot (be expected to) install a LaTeX distribution themselves. The target group uses Windows exclusively.

I use Linux. I used mkjobtexmf with the --strace option and recursively resolved all symlinks in order to obtain a portable texmf-tree. In order to test the setup, I generated the following directory layout

- texmf: a dump of the generated .mjt texmf-tree
- bin
  - win32: contains the lualatex.exe and relevant DLLs as not to throw an error
- report.tex: A test file that should print a string

Loosely following the Github example by Deepak Jois for plain LuaTeX, based on the series of blog posts by Graham Douglas, I set up the texmf.cnf in the web2c directory as


Upon running

bin/win32/lualatex --fmt=texmf/web2c/lualatex.fmt ./report.tex

the following error is thrown:

This is LuaTeX, Version 1.10.0 (TeX Live 2019/W32TeX)
(./report.tex[\directlua]:1: module 'lualatexquotejobname.lua' not found:
        no field package.preload['lualatexquotejobname.lua']
        [kpse lua searcher] file not found: 'lualatexquotejobname.lua'
        [kpse C searcher] file not found: 'lualatexquotejobname.lua'
        no file 'Z:\rhdhv-koploper-tool\src\latex\bin\win32\lualatexquotejobname.dll'
        no file 'Z:\rhdhv-koploper-tool\src\latex\bin\win32\..\lib\lua\5.3\lualatexquo
        no file 'Z:\rhdhv-koploper-tool\src\latex\bin\win32\loadall.dll'
        no file '.\lualatexquotejobname.dll'
stack traceback:
        [C]: in function 'require'
        [\directlua]:1: in main chunk.
<everyjob> \directlua {require("lualatexquotejobname.lua")}
                                                \typeout {\fmtname \space <\fmt
  % This document has been generated automatically by rhdhv-koploper-tool
! Emergency stop.
<everyjob> \directlua {require("lualatexquotejobname.lua")}
                                                \typeout {\fmtname \space <\fmt
  % This document has been generated automatically by rhdhv-koploper-tool
 275 words of node memory still in use:
   1 hlist, 1 dir, 39 glue_spec nodes
   avail lists: 2:12,3:1,4:1,5:2
!  ==> Fatal error occurred, no output PDF file produced!
Transcript written on report.log.

Attempting to regenerate the .fmt file with

bin/win32/luatex -ini "&lualatex" ./report.tex

reports that lualatex.fmt could not be found. Dumping the contents of texlive\bin\win32\ into root\bin\win32 does not alter anything.

I have stumbled upon "lualatex on Mac module 'lualatexquotejobname.lua' not found error" on SE, which has lead me to believe that this is an issue with inappropriately set environment variables, but has not given me any ideas as to how to resolve this. If I use C:\texlive\bin\win32\lualatex instead, the test file compiles flawlessly, albeit without using the .sty files from the portable texmf-tree. Setting the TEXMFDIST variable with


leads to the same error.

  • do you have texmf-dist/tex/latex/latexconfig/lualatexquotejobname.lua but your paths are wrong, or do you not have it? – David Carlisle Apr 5 '20 at 16:41
  • Thank you for your quick response. I do indeed have that file—it was put in the right place by mkjobtexmf. – user169291 Apr 5 '20 at 16:45
  • well luatex isn't finding it... [kpse lua searcher] file not found: 'lualatexquotejobname.lua' (the later errors are spurious, this one is supposed to have worked, so either the file is not in your lua input path or it is but you have not run mktexlsr or .... – David Carlisle Apr 5 '20 at 16:49
  • what is LUAINPUTS set to ? – David Carlisle Apr 5 '20 at 16:51
  • Nothing at the moment; I figured that should be resolved automatically as TEXMFDIST is set to the appropriate place and changing this in texmf.cnf does nothing. I will try to set all relevant environment variables (TEXMF, WEB2C, TEXINPUTS, and TEXFORMATS, right?) in PowerShell and report back. – user169291 Apr 5 '20 at 16:55

So, I figured I'd better submit an answer just in case that someone else wonders the same thing in the future.

This is a textbook example of the XY problem. I attempted to correct the paths via environment variables. As David Carlisle pointed out in his comments, this is not the correct way to do it and may lead to problems heaping up.

I've fixed all the errors and the software is now being used. My process to generating a portable distribution was as follows:

  1. Find out which binaries you will need. In my case I only needed lualatex.exe (and the corresponding lua53.dll and lualatex.dll-s) as I do not have a bibliography and use the mktexlsr on my Linux system. This can be done with a DLL dependency walker.
  2. Use mkjobtexmf to get a rough estimate of the texmf tree required to compile the .tex you want.
  3. Compile the .tex with the distribution engine to generate a lualatex.fmt.
  4. Make a .cnf file. At the bare minimum, the array and buffer sizes will need to be set, together with the paths relative to $SELFAUTOPARENT. This can be copied form a plain TeX distribution, with the exception of having to add the OPENTYPEFONTS (if applicable), LUAINPUTS, and TEXMFSCRIPTS folders.
  5. As discussed in another question on portable distributions, other .cnf files can be modified as well to further reduce the distribution size.

As a ballpark estimate on size: this distribution is 26 MB and capable of compiling an engineering report with three .otf fonts and figures made with TikZ and pgfplots. Compressed to a .zip that is out-of-the-box compatible with Windows, that's just short of 8 MB (7z, default settings).

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.