0

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

root
- 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

TEXMF=Z:/rhdhv-koploper-tool/src/latex/texmf
WEB2C=$TEXMF/web2c
TEXINPUTS=.:$TEXMF/tex//
TEXFONTMAPS=$TEXMF/fonts/map
TEXFORMATS=$TEXMF/web2c
TFMFONTS=$TEXMF/fonts/tfm//
T1FONTS=$TEXMF/fonts/type1//
ENCFONTS=$TEXMF/fonts/enc

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
tejobname.dll'
        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
l.1
  % This document has been generated automatically by rhdhv-koploper-tool
?
! Emergency stop.
<everyjob> \directlua {require("lualatexquotejobname.lua")}
                                                \typeout {\fmtname \space <\fmt
l.1
  % 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

$Env:TEXMFDIST="Z:\rhdhv-koploper-tool\src\latex\texmf"

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 05 '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 05 '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 05 '20 at 16:49
  • what is LUAINPUTS set to ? – David Carlisle Apr 05 '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 05 '20 at 16:55
  • usually you do not need to set any environment variables other than PATH but you can set them if you wish rather than use texmf. CNG but it is LUAINPUTS that looks wrong – David Carlisle Apr 05 '20 at 18:32
  • Thanks you so much! It was indeed the LUAINPUTS that was set incorrectly. Now I just have to resolve the other errors that arose from having fixed this. If it is not too much: could you please explain why LUAINPUTS is not inferred directly from having set the TEXMF and/or dist/local environment variables, as you alluded to in your previous comment? – user169291 Apr 05 '20 at 19:08
  • well the defaults set up all the various paths in a consistent way but once you start over-riding individual ones with environment variables it's easy to get them out of line. LUAINPUTS defaults to LUAINPUTS.lualatex = $TEXMFDOTDIR;$TEXMF/scripts/{$progname,$engine,}/{lua,}//;$TEXMF/tex/{lualatex,latex,luatex,generic,}// whereas TEXMFDIST defaults to TEXMFDIST = $TEXMFROOT/texmf-dist here you have reset TEXMFDIST but not TEXMFROOT so LUAINPUTS won't have changed. – David Carlisle Apr 05 '20 at 20:05

1 Answers1

0

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).

  • @Vimieiro Do you still want to see an MWE? – user169291 Mar 30 '21 at 19:55
  • Very well, I'll see what I can cook up this weekend! – user169291 Apr 01 '21 at 12:33
  • @Vimieiro My apologies for the delayed response; I had considerable personal problems that I had to take care of.

    Upon trying to recreate my original setup, I had to reinstall Windows in a virtual machine and noticed that VCRUNTIME140.dll, among others, was missing. Supplying these DLLs was previously not required. To prevent issues such as these, may I suggest that you try to apply my answer yourself? I am of course willing to guide you through any issues you may encounter along the way.

    – user169291 Apr 18 '21 at 18:07
  • @user169291Thank you for all the effort. I was able to generate a MWE for pdflatex, which suppressed my needs. I'll let you know if I get something on lualatex. Thank you anyways!! – rvimieiro Apr 19 '21 at 10:50
  • 1
    @Vimieiro Don't mention it. Best of luck! And indeed, if you encounter any issues with luatex just hit me up. – user169291 Apr 20 '21 at 11:20