Subject: 12.1.1; Preview with cached preamble fails with lualatex engine and filenames with spaces

From: jfbu <[email-masked]>
Date: Sat, 2 Jun 2018 14:12:20 +0200

Hi,

consider this file

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

and switch engine to luatex.

Then generate previews for document, answering yes to caching preamble.

This fails 

1. the cached format can not be generated

Running `Preview-LaTeX' on `abc def ghi' with ``lualatex -ini -interaction=nonstopmode "&lualatex" prv_abc_def_ghi.ini \ def\ ghi  -file-line-error   "\nonstopmode\nofiles\PassOptionsToPackage{active,tightpage,auctex}{preview}\AtBeginDocument{\ifx\ifPreview\undefined\RequirePackage[displaymath,floats,graphics,textmath,sections,footnotes]{preview}[2004/11/05]\fi}" "\input" \"abc\ def\ ghi.tex\"''

notice that the above is ill-formed (see \ def\ ghi -file-line-error) bit

This is LuaTeX, Version 1.07.0 (TeX Live 2018)  (INITEX)
 restricted system commands enabled.
(./prv_abc_def_ghi.ini
LaTeX2e <2018-04-01> patch level 5
(using write cache: /usr/local/texlive/2018/texmf-var/luatex-cache/generic)(using read cache: /usr/local/texlive/2018/texmf-var/luatex-cache/generic /Users/jfb/Library/texlive/2018/texmf-var/luatex-cache/generic)
luaotfload | main : initialization completed in 0.116 seconds (/usr/local/texlive/2018/texmf-dist/tex/latex/carlisle/mylatex.ltx))
! I can't find file `def'.
<*> &lualatex prv_abc_def_ghi.ini  def 
                                    ghi -file-line-error \nonstopmode\nofile...
(Press Enter to retry, or Control-D to exit)
Please type another input file name
! Emergency stop.
<*> &lualatex prv_abc_def_ghi.ini  def 
                                    ghi -file-line-error \nonstopmode\nofile...
 246 words of node memory still in use:
   1 dir, 35 glue_spec nodes
   avail lists: 2:12,3:1,4:1
!  ==> Fatal error occurred, no output PDF file produced!
Transcript written on prv_abc_def_ghi.log.

2. even the fallback of not using cached preamble fails  (see bug #31684)

Running `Preview-LaTeX' on `abc def ghi' with ``lualatex --jobname=abc\ def\ ghi  -file-line-error   "\nonstopmode\nofiles\PassOptionsToPackage{active,tightpage,auctex}{preview}\AtBeginDocument{\ifx\ifPreview\undefined\RequirePackage[displaymath,floats,graphics,textmath,sections,footnotes]{preview}[2004/11/05]\fi}" "\input" \"abc\ def\ ghi.tex\"''
This is LuaTeX, Version 1.07.0 (TeX Live 2018) 
 restricted system commands enabled.
LaTeX2e <2018-04-01> patch level 5
(using write cache: /usr/local/texlive/2018/texmf-var/luatex-cache/generic)(using read cache: /usr/local/texlive/2018/texmf-var/luatex-cache/generic /Users/jfb/Library/texlive/2018/texmf-var/luatex-cache/generic)
luaotfload | main : initialization completed in 0.108 seconds
No auxiliary output files.

("./abc def ghi.tex" (/usr/local/texlive/2018/texmf-dist/tex/latex/base/article.cls
Document Class: article 2014/09/29 v1.4h Standard LaTeX document class
(/usr/local/texlive/2018/texmf-dist/tex/latex/base/size10.clo(load luc: /usr/local/texlive/2018/texmf-var/luatex-cache/generic/fonts/otl/lmroman10-regular.luc)))
No file "abc def ghi".aux.
(/Users/jfb/.emacs.d/elpa/auctex-12.1.1/latex/preview.sty (/usr/local/texlive/2018/texmf-dist/tex/generic/luatex85/luatex85.sty) (/Users/jfb/.emacs.d/elpa/auctex-12.1.1/latex/prtightpage.def) (/Users/jfb/.emacs.d/elpa/auctex-12.1.1/latex/prauctex.def
No auxiliary output files.

(/Users/jfb/.emacs.d/elpa/auctex-12.1.1/latex/prauctex.cfg)) (/Users/jfb/.emacs.d/elpa/auctex-12.1.1/latex/prfootnotes.def)
Preview: Fontsize 10pt
Preview: PDFoutput 1
)
./abc def ghi.tex:4: Preview: Snippet 1 started.
<-><->
      
l.4 $
   \abc$
Preview: Tightpage -32891 -32891 32891 32891
./abc def ghi.tex:4: Preview: Snippet 1 ended.(455111+0x911285).
<-><->
      
l.4 $\abc$
        
[1{/usr/local/texlive/2018/texmf-var/fonts/map/pdftex/updmap/pdftex.map}])
(see the transcript file for additional information)
 362 words of node memory still in use:
   2 hlist, 1 vlist, 1 rule, 2 glue, 4 attribute, 45 glue_spec, 4 attribute_list, 2 write nodes
   avail lists: 2:14,3:3,4:1,5:11,6:1,7:7,8:3,9:2
</usr/local/texlive/2018/texmf-dist/fonts/type1/public/amsfonts/cm/cmmi10.pfb>
Output written on abc def ghi.pdf (1 page, 8584 bytes).
Transcript written on "abc def ghi.log".

TeX Output exited as expected with code 1 at Sat Jun  2 14:03:07
Running `Preview-DviPNG' with ``dvipng -picky -noghostscript abc\ def\ ghi.dvi -o "abc\ def\ ghi.prv/tmp14898GFt/prev%03d.png"  -D186 ''
Parser: End of Preview snippet 1 unexpected

Preview-DviPNG killed: 9 at Sat Jun  2 14:03:07

Related notes:

1. Actually caching the preamble when using lualatex is very fragile. It would break or
at least be in inconsistent state if any Lua code is executed in the preamble.

Nevertheless, for simple file above, if filename has no spaces, then preview generation
appears to work as expected (in PDF mode, luatex engine)

2. When using xelatex, the situation is even simpler, it is impossible currently
to use mylatex.ltx with it. https://github.com/davidcarlisle/dpctex/issues/15

This is with AUCTeX 12.1.1.

Jean-François