I am trying to use mylatexformat to precompile my lengthy preamble, which is basically all in my custom .cls, with the remaining bit of non-static preamble at the top of my main.tex, before which I put \csname endofdump\endcsname (I have also tried just \endofdump). I use VSCode (LaTeX Workshop) and my distribution is MiKTeX. I have successfully generated the main.fmt file by using the command lualatex -ini -jobname="main" --shell-escape "&lualatex" mylatexformat.ltx "main.tex". Once I have the .fmt, I put %&main on the very first line of my main.tex and run the command lualatex --shell-escape "&main" main.tex, however, I keep on getting this error:
(./main.tex[\directlua]:1: attempt to index a nil value (global 'shellesc')
stack traceback:
[\directlua]:1: in main chunk.
\write ->\directlua {shellesc.write_or_execute()}
I thought this might be due to me not having the shellesc.sty tool in MiKTeX, but I do, and --shell-escape is working and produces minted output, when I'm not using mylatexformat ofcourse. A very similar error shows up here, but their issue was fixed by just installing a missing package it seems.
Here is my main.log directly after generating the .fmt, and here is a log file after issuing the second command.
I can't think of any other details to include to help the debug process, but can definitely add more if needed. Although I am running it using lualatex, I ultimately want to be able to use latexmk -lualatex ... for automation, but I don't know if that's possible with mylatexformat...
\write18mechanism to access the shell so minted (via shellesc package) uses Lua to access the shell if used by luatex, but if you load shellesc.sty into the format the tex interface is saved but all the underlying Lua definitions are dropped so, as you show you get undefiend names in Lua – David Carlisle Apr 20 '21 at 11:04.cls(excluding the lualatex dependent fonts, etc.) in pdflatex for example, and then added the font in the dynamic part of the preamble and compiled with lualatex? – Daniel Jakob Apr 20 '21 at 12:14mylatexformatto speed up compiling or to just reduced pre-amble? For the latter, you can just make a standalone file for your pre-amble as a .sty and useRequirePackage. I usedmylatexformata fair bit in the past, but didn't really notice compile speed improvement. Not that important to me anyways. – likethevegetable Apr 20 '21 at 21:58\RequirePackages and settings in my customlabreport.clsclass file. Is this different from using a.sty? – Daniel Jakob Apr 21 '21 at 16:15