# lualatex bug confuses latexmk dependency tracking

The described issue has been confirmed as a bug in luatex that can be expected to be solved in TeXLive 2018. Also latexmk itself has been extended to deal with this issue in version 4.55d.

For a large deck of lecture slides I am refactoring my custom Makefile into a more streamlined solution based on latexmk with the -use-make option.

While this works fine with pdflatex as engine, it causes lot's of make invocations with lualatex for targets that are actually part of the texmf tree. Minimal example:

% slides.tex
\RequirePackage{luatex85}
\documentclass{beamer}

\begin{document}
\begin{frame}{A Frame}
Some content
\end{frame}

\end{document}


If I compile this with

latexmk -lualatex -norc -use-make slides.tex


(-norc to make sure no hidden options are passed to latexmk)

Compilation works, but I get the following:

Latexmk: This is Latexmk, John Collins, 19 Jan. 2017, version: 4.52c.
Latexmk: 'lualatex': source file 'beamericonarticle.20.pdf' doesn't exist. I'll try making it...
------------
Running 'make "beamericonarticle.20.pdf"'
------------
make: *** No rule to make target beamericonarticle.20.pdf'.  Stop.
Latexmk: 'lualatex': source file 'beamericonarticle.pdf' doesn't exist. I'll try making it...
------------
Running 'make "beamericonarticle.pdf"'
------------
make: *** No rule to make target beamericonarticle.pdf'.  Stop.
<... and so on ..,>
Latexmk: All targets (slides.pdf) are up-to-date


I assume the culprit comes from the fact, that lualatex behaves slightly different to pdflatex with respect to the -recorder option, which is (AFAIK) employed by latexmk for input dependency tracking. In the lualatex version we find one extra line in the generated slides.fls file for every included image:

INPUT /opt/local/share/texmf-texlive/tex/latex/beamer/art/beamericonarticle.pdf
INPUT beamericonarticle.pdf      <-- not generated by pdflatex!
INPUT /opt/local/share/texmf-texlive/tex/latex/beamer/art/beamericonarticle.20.pdf
INPUT beamericonarticle.20.pdf   <-- not generated by pdflatex!


So apparently, latexmk does not know what to make out of these "extra" INPUTs and, thus, calls make to build them.

Employed Versions:

This is LuaTeX, Version 1.0.4 (TeX Live 2017/MacPorts 2017_2)

Latexmk, John Collins, 19 Jan. 2017. Version 4.52c

Questions:

• Is this a bug or a feature of lualatex?
• Or maybe the lua-specific part of the graphics driver is to blame here?
• Possible workarounds?
• I don't get the short version INPUT beamericonarticle.pdf with miktex, only with texlive (2017 and 2018). So I think it should be reported on the texlive mailing list, I will do it. – Ulrike Fischer Mar 15 '18 at 10:11
• @UlrikeFischer: Thanks. This also has reminded me to always include version information. – Daniel Mar 15 '18 at 10:24
• This has been corrected in the luatex sources. So it should be okay in tl18. – Ulrike Fischer Mar 16 '18 at 12:16

For those who are adventurous enough to fiddle around with the (amazingly well documented!) latexmk source code, I have a quick workaround:
The following lines should be inserted in parse_fls function definition (sub parse_fls):
4588         elsif (/^\s*INPUT\s+([^\/]*)$/) { 4589 # Ignore entries without any directory part 4590 # Those are additionally inserted in some versions of lualatex 4591 # see: https://tex.stackexchange.com/questions/420274 4592 next; 4593 }  Note that the line numbers will vary, depending on the precise version of latexmk. They should be inserted before the following existing lines: 4594 elsif (/^\s*INPUT\s+(.*)$/) {

• I've put an improved improvement in v. 4.55b of latexmk at personal.psu.edu/jcc8/latexmk/versions.html In this version, latexmk tests whether the name in a INPUT line of the fls file corresponds to an actual file. If the file doesn't exist, latexmk doesn't consider the file as a dependency and types out a prominent warning message. – John Collins Mar 15 '18 at 17:50
• @JohnCollins: How would that interact with the -use-make option, which, AFAIU is supposed to invoke make for nonexistent dependencies? – Daniel Mar 16 '18 at 6:05
• It will make the interaction with -use-make better. Dependency information is from both the .fls and .log files. If a file is reported in the .fls file but latexmk finds it doesn't exist, then either it's because of a bug (as in lualatex) or because the file got deleted (as with temporary files in the minted package). In either case, it is not a true dependency. But missing files deduced from the .log file are correctly potential dependencies for which make could be used. The new latexmk hasn't changed its behavior for those. – John Collins Mar 16 '18 at 21:07
• @JohnCollins: Thanks, I can confirm that 4.55d works well around the issue! However, I found a (probably) related one with lualatex and the output file: If I add -output-directory=./build to the command line in the question, latexmk always warns Latexmk: ===For rule 'lualatex', actual output 'slides.pdf' appears not to match expected output './build/slides.pdf'. Again this does not happen with pdflatex as engine. – Daniel Mar 17 '18 at 20:46
• You can safely ignore the warning message about the output filenames from lualatex not matching. This is caused by an annoying quirk of lualatex compared with the other engines. It doesn't affect the functioning of latexmk, so I plan to change latexmk so that it won't produce a warning in this case. (There are other cases where a warning could be useful, but this isn't one of them.) – John Collins Mar 19 '18 at 15:10