davidcarlisle/dpctex

mylatex.ltx cannot load file with empty name under specific condition

Closed this issue · 3 comments

Consider the following examples:

--- abc.tex ---

\documentclass{article}
\begin{document}
abc
\end{document}

--- abc.ini ---

\input mylatex.ltx \relax%

Make a subdirectory named "build" by mkdir build.

Then the following command leads to error:
lualatex -ini --output-directory=build/ \&lualatex abc.ini "\nonstopmode" "\input" abc.tex
The output is

This is LuaHBTeX, Version 1.15.0 (TeX Live 2022)  (INITEX)
 restricted system commands enabled.
(./abc.ini
LaTeX2e <2021-11-15> patch level 1
 L3 programming layer <2022-02-24>
(/usr/local/texlive/2022/texmf-dist/tex/latex/mylatex/mylatex.ltx))
! I can't find file `'.
<to be read again> 
\nonstopmode 
<*> &lualatex abc.ini \nonstopmode
                                \input abc.tex
(Press Enter to retry, or Control-D to exit)
Please type another input file name:^D  
! Emergency stop.
<to be read again> 
\nonstopmode 
<*> &lualatex abc.ini \nonstopmode
                                \input abc.tex
 301 words of node memory still in use:
   1 hlist, 1 dir, 3 kern, 1 glyph, 1 attribute, 39 glue_spec, 1 attribute_list
 nodes
   avail lists: 2:10,3:3,4:1
!  ==> Fatal error occurred, no output PDF file produced!
Transcript written on abc.log.

However, any of the following variants runs without error:
lualatex -ini \&lualatex abc.ini "\nonstopmode" "\input" abc.tex (omitting --output-directory option)
lualatex -ini --output-directory=build/ \&lualatex abc.ini abc.tex (without \TeXcode \input syntax)
pdflatex -ini --output-directory=build/ \&pdflatex abc.ini "\nonstopmode" "\input" abc.tex (pdflatex instead of lualatex)
In other words, the error occurs only with the combination of lualatex, \TeXcode \input and --output-directory option. This affects preview-latex, subsystem of AUCTeX: https://lists.gnu.org/archive/html/auctex/2022-06/msg00020.html

Is there any fix or workaround for this error?

Originally posted by @ikumikeita in #15 (comment)

@davidcarlisle It seems that I failed to convey my point in the previous post. I try to explain it.

You can not save Lua state or OpenType fonts in the format, so typically you need to alter the package code to delay Lua and font loading to \everyjob

First of all, this issue has nothing to do with OpenType fonts nor Lua code, at least at superficial level, by the following reasons.

  1. The example code abc.tex and abc.ini have no OpenType nor Lua contents at all.
  2. As stated in the previous post, dumping format succeeds if --output-directory=build/ is omitted.
  3. As stated in the previous post, dumping format succeeds if "\nonstopmode" "\input" isn't present.

In the quote in the above post, lualatex tells that the reason of the fail as:

! I can't find file `'.

It refers to a file with empty name. This is because abc.ini ends with \relax% to specify empty file name, actually a file with file name of .tex, which consists totally of extension only. This file .tex resides at /usr/local/texlive/2022/texmf-dist/tex/latex/tools/.tex on my machine.
When I issue the command mentioned in 2. or 3. of the above list, the console log is as follows:

This is LuaHBTeX, Version 1.15.0 (TeX Live 2022)  (INITEX)
 restricted system commands enabled.
(./abc.ini
LaTeX2e <2021-11-15> patch level 1
 L3 programming layer <2022-02-24>
(/usr/local/texlive/2022/texmf-dist/tex/latex/mylatex/mylatex.ltx))
(/usr/local/texlive/2022/texmf-dist/tex/latex/tools/.tex File ignored)
(./abc.tex (/usr/local/texlive/2022/texmf-dist/tex/latex/base/article.cls
Document Class: article 2021/10/04 v1.4n Standard LaTeX document class
(/usr/local/texlive/2022/texmf-dist/tex/latex/base/size10.clo)))
Beginning to dump on file abc.fmt
 (format=abc 2022.6.16)
22488 strings using 389714 bytes
686491 memory locations dumped; current usage is 340&318329
21071 multiletter control sequences
\font\nullfont=nullfont
[...]
32 preloaded fonts
warning  (pdf backend): no pages of output.
Transcript written on abc.log.

In this case, lualatex does load .tex as

(/usr/local/texlive/2022/texmf-dist/tex/latex/tools/.tex File ignored)

, albeit saying File ignored.

From these observations, I infer that this issue isn't related to OpenType nor Lua. Assuming my inference is correct, my concern is

  1. Why the option --output-dir disables loading .tex?
  2. Why "\nonstopmode" "\input" disables loading .tex?
  3. Is there any workaround to keep mylatex.ltx able to load .tex even when both --output-dir and "\nonstopmode" "\input" are present?
jfbu commented

I think this is an upstream luatex problem as this reduced example not invoving mylatex.ltx shows: (my example are on a Bash shell with up-to-date TL2022)

  1. lualatex --output-directory=build/ '\input\relax' '\input' sample2e fails with the message about missing file `'
  2. lualatex '\input\relax' '\input' sample2e succeeds (but one should use -jobname to avoid creating .pdf)
  3. if a file .tex is located in build/ directory case 1. succeeds. (one should use -jobname)
  4. replacing lualatex by pdflatex in case 1. it works even without a file .tex in build/. (one should use -jobname)

@ikumikeita The File ignored comes from file .tex in /usr/local/texlive/2022/texmf-dist/tex/latex/tools/ whose non-commented contents are

 \message{File ignored}
\endinput

Perhaps in your original problem you can work around it by making sure a .tex file pre-exists in build/?

In case of pdflatex start of log shows

This is pdfTeX, Version 3.141592653-2.6-1.40.24 (TeX Live 2023/dev) (preloaded format=pdflatex 2022.6.16)  17 JUN 2022 08:18
entering extended mode
 restricted \write18 enabled.
 %&-line parsing enabled.
**\input\relax \input sample2e

(/usr/local/texlive/2022/texmf-dist/tex/latex/tools/.tex File ignored)

In case of lualatex one can answer the error prompt providing filename .tex and then build succeeds (here I am using a fresh build2/):

$ lualatex --output-directory=build2/ '\input\relax' '\input' sample2e 
This is LuaHBTeX, Version 1.15.1 (TeX Live 2023/dev) 
 restricted system commands enabled.
LaTeX2e <2022-06-01> pre-release-0 (develop 2022-6-16 branch)
L3 programming layer <2022-06-02>
! I can't find file `'.
<to be read again> 
\let 
<*> \input\relax \input
                     sample2e
(Press Enter to retry, or Control-D to exit)
Please type another input file name: .tex
(/usr/local/texlive/2022/texmf-dist/tex/latex/tools/.tex File ignored)
(/usr/local/texlive/2022/texmf-dist/tex/latex/base/sample2e.tex
(/usr/local/texlive/2022/texmf-dist/tex/latex/base/article.cls
Document Class: article 2021/10/04 v1.4n Standard LaTeX document class
(/usr/local/texlive/2022/texmf-dist/tex/latex/base/size10.clo))
(/usr/local/texlive/2022/texmf-dist/tex/latex/l3backend/l3backend-luatex.def)
(./.aux) (/usr/local/texlive/2022/texmf-dist/tex/latex/base/ts1cmr.fd) [1{/usr/
local/texlive/2022/texmf-var/fonts/map/pdftex/updmap/pdftex.map}] [2] [3]
(./build2//.aux))
 421 words of node memory still in use:
   3 hlist, 1 vlist, 1 rule, 3 glue, 3 kern, 1 glyph, 6 attribute, 48 glue_spec
, 6 attribute_list, 1 write nodes
   avail lists: 2:316,3:133,4:11,5:343,6:41,7:5027,8:14,9:200,10:7,11:280
</usr/local/texlive/2022/texmf-dist/fonts/opentype/public/lm/lmroman8-regular.o
tf></usr/local/texlive/2022/texmf-dist/fonts/opentype/public/lm/lmroman6-regula
r.otf></usr/local/texlive/2022/texmf-dist/fonts/opentype/public/lm/lmroman10-it
alic.otf></usr/local/texlive/2022/texmf-dist/fonts/opentype/public/lm/lmroman7-
regular.otf></usr/local/texlive/2022/texmf-dist/fonts/opentype/public/lm/lmroma
n12-bold.otf></usr/local/texlive/2022/texmf-dist/fonts/opentype/public/lm/lmrom
an10-regular.otf></usr/local/texlive/2022/texmf-dist/fonts/opentype/public/lm/l
mroman12-regular.otf></usr/local/texlive/2022/texmf-dist/fonts/opentype/public/
lm/lmroman17-regular.otf></usr/local/texlive/2022/texmf-dist/fonts/type1/public
/amsfonts/cm/cmex10.pfb></usr/local/texlive/2022/texmf-dist/fonts/type1/public/
amsfonts/cm/cmmi10.pfb></usr/local/texlive/2022/texmf-dist/fonts/type1/public/a
msfonts/cm/cmmi7.pfb></usr/local/texlive/2022/texmf-dist/fonts/type1/public/ams
fonts/cm/cmr10.pfb></usr/local/texlive/2022/texmf-dist/fonts/type1/public/amsfo
nts/cm/cmr7.pfb></usr/local/texlive/2022/texmf-dist/fonts/type1/public/amsfonts
/cm/cmsy10.pfb></usr/local/texlive/2022/texmf-dist/fonts/type1/public/amsfonts/
cm/cmsy7.pfb>
Output written on .pdf (3 pages, 89064 bytes).
Transcript written on .log.

@jfbu Thank you, I understand that mylatex.ltx is not responsible for this issue. I'll ask on luatex developers' list.

@ikumikeita The File ignored comes from file .tex in /usr/local/texlive/2022/texmf-dist/tex/latex/tools/ whose non-commented contents are

 \message{File ignored}
\endinput

Oh, sorry & thanks. I thought that the file is just empty.