Subject: Document preview fails with long filenames

From: John Holman <[email-masked]>
Date: Wed, 30 Aug 2023 15:05:03 +0100

Hi. I'm not sure that the problem was captured in the log below created
by preview-report-bug so a few more details first:

Running auctex on windows 11 with MiKTeX

Test file contents (but most files containing maths seem to trigger the
problem)

\documentclass{article}
\begin{document}

\(x=y\)

\end{document}

Document preview works when the filename has no more than 22 characters,
e.g. test.tex, but fails with message "Ghostscript filter: No bounding box"
when the filename has more, e.g. 01234567890123456789012.tex. However
buffer preview always works.

When document preview fails the maths sections are replaced with the
roadworks signs indefinitely. The 01234567890123456789012.prv directory is
created
containing a temp folder containing a preview.dsc file but no png
images. The rungs.exe and mgs.exe processes don't exit until killed manually
or emacs is closed.

The contents of the *.. output* buffer are then

Running `Preview-LaTeX' on `012345678901234546789012' with ``pdflatex
 -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" "\detokenize{" "012345678901234546789012.tex" "}"''
This is pdfTeX, Version 3.141592653-2.6-1.40.25 (MiKTeX 23.5) (preloaded
format=pdflatex.fmt)
 restricted \write18 enabled.
entering extended mode
LaTeX2e <2023-06-01> patch level 1
L3 programming layer <2023-08-11>

No auxiliary output files.

(012345678901234546789012.tex
(C:\Users\johng\AppData\Local\Programs\MiKTeX\tex/latex/base\article.cls
Document Class: article 2023/05/17 v1.4n Standard LaTeX document class
(C:\Users\johng\AppData\Local\Programs\MiKTeX\tex/latex/base\size10.clo))
(C:\Users\johng\AppData\Local\Programs\MiKTeX\tex/latex/l3backend\l3backend-pdf
tex.def)
No file 012345678901234546789012.aux.
(c:/Users/johng/.emacs.d/elpa/auctex-13.2.1/latex\preview.sty
(C:\Users\johng\AppData\Local\Programs\MiKTeX\tex/latex/luatex85\luatex85.sty)
(c:/Users/johng/.emacs.d/elpa/auctex-13.2.1/latex\prtightpage.def)
(c:/Users/johng/.emacs.d/elpa/auctex-13.2.1/latex\prauctex.def
No auxiliary output files.

(c:/Users/johng/.emacs.d/elpa/auctex-13.2.1/latex\prauctex.cfg))
(c:/Users/johng/.emacs.d/elpa/auctex-13.2.1/latex\prfootnotes.def)
Preview: Fontsize 10pt
Preview: PDFoutput 1
)
012345678901234546789012.tex:4: Preview: Snippet 1 started.
<-><->

l.4 \(
      x=y\)
Preview: Tightpage -32891 -32891 32891 32891
012345678901234546789012.tex:4: Preview: Snippet 1
ended.(282168+127431x1593186
).
<-><->

l.4 \(x=y\)

[1{C:/Users/johng/AppData/Local/MiKTeX/fonts/map/pdftex/pdftex.map}] )
(see the transcript file for additional
information)<C:/Users/johng/AppData/Loc
al/Programs/MiKTeX/fonts/type1/public/amsfonts/cm/cmmi10.pfb><C:/Users/johng/Ap
pData/Local/Programs/MiKTeX/fonts/type1/public/amsfonts/cm/cmr10.pfb>
Output written on 012345678901234546789012.pdf (1 page, 17918 bytes).
Transcript written on 012345678901234546789012.log.

TeX Output exited as expected with code 1 at Wed Aug 30 14:49:41
Running `Preview-PDF2DSC' with ``pdf2dsc "012345678901234546789012.pdf"
"012345678901234546789012.prv/tmpqz9sI5"/preview.dsc''

Preview-PDF2DSC finished at Wed Aug 30 14:49:42
Running `Preview-Ghostscript' with
``"c:/Users/johng/AppData/Local/Programs/MiKTeX/miktex/bin/x64/rungs.exe"
^"-sOutputFile=012345678901234546789012.prv/tmpqz9sI5/pr1-^%d.png^" "-q"
"-dDELAYSAFER" "-dNOPAUSE" "-DNOPLATFONTS" "-dPrinted" "-dTextAlphaBits=4"
"-dGraphicsAlphaBits=4" "-sDEVICE=png16m" "-r106.74x106.68"''
Ghostscript filter: No bounding box

===

Emacs  : GNU Emacs 29.1 (build 2, x86_64-w64-mingw32)
 of 2023-08-02
Package: 13.2.1

Run buffer contents:

Running `Preview-LaTeX' on `012345678901234546789012' with ``pdflatex
 -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" "\detokenize{" "012345678901234546789012.tex" "}"''
This is pdfTeX, Version 3.141592653-2.6-1.40.25 (MiKTeX 23.5) (preloaded
format=pdflatex.fmt)
 restricted \write18 enabled.
entering extended mode
LaTeX2e <2023-06-01> patch level 1
L3 programming layer <2023-08-11>

No auxiliary output files.

(012345678901234546789012.tex
(C:\Users\johng\AppData\Local\Programs\MiKTeX\tex/latex/base\article.cls
Document Class: article 2023/05/17 v1.4n Standard LaTeX document class
(C:\Users\johng\AppData\Local\Programs\MiKTeX\tex/latex/base\size10.clo))
(C:\Users\johng\AppData\Local\Programs\MiKTeX\tex/latex/l3backend\l3backend-pdf
tex.def)
No file 012345678901234546789012.aux.
(c:/Users/johng/.emacs.d/elpa/auctex-13.2.1/latex\preview.sty
(C:\Users\johng\AppData\Local\Programs\MiKTeX\tex/latex/luatex85\luatex85.sty)
(c:/Users/johng/.emacs.d/elpa/auctex-13.2.1/latex\prtightpage.def)
(c:/Users/johng/.emacs.d/elpa/auctex-13.2.1/latex\prauctex.def
No auxiliary output files.

(c:/Users/johng/.emacs.d/elpa/auctex-13.2.1/latex\prauctex.cfg))
(c:/Users/johng/.emacs.d/elpa/auctex-13.2.1/latex\prfootnotes.def)
Preview: Fontsize 10pt
Preview: PDFoutput 1
)
012345678901234546789012.tex:4: Preview: Snippet 1 started.
<-><->

l.4 \(
      x=y\)
Preview: Tightpage -32891 -32891 32891 32891
012345678901234546789012.tex:4: Preview: Snippet 1
ended.(282168+127431x1593186
).
<-><->

l.4 \(x=y\)

[1{C:/Users/johng/AppData/Local/MiKTeX/fonts/map/pdftex/pdftex.map}] )
(see the transcript file for additional
information)<C:/Users/johng/AppData/Loc
al/Programs/MiKTeX/fonts/type1/public/amsfonts/cm/cmmi10.pfb><C:/Users/johng/Ap
pData/Local/Programs/MiKTeX/fonts/type1/public/amsfonts/cm/cmr10.pfb>
Output written on 012345678901234546789012.pdf (1 page, 17918 bytes).
Transcript written on 012345678901234546789012.log.

TeX Output exited as expected with code 1 at Wed Aug 30 14:44:32
Running `Preview-PDF2DSC' with ``pdf2dsc "012345678901234546789012.pdf"
"012345678901234546789012.prv/tmp3SwYcB"/preview.dsc''

Preview-PDF2DSC finished at Wed Aug 30 14:44:32
Running `Preview-Ghostscript' with
``"c:/Users/johng/AppData/Local/Programs/MiKTeX/miktex/bin/x64/rungs.exe"
^"-sOutputFile=012345678901234546789012.prv/tmp3SwYcB/pr1-^%d.png^" "-q"
"-dDELAYSAFER" "-dNOPAUSE" "-DNOPLATFONTS" "-dPrinted" "-dTextAlphaBits=4"
"-dGraphicsAlphaBits=4" "-sDEVICE=png16m" "-r106.74x106.68"''
Ghostscript filter: No bounding box

current state:
==============
(setq
 AUCTeX-version "13.2.1"
 LaTeX-command-style '((""
"%(PDF)%(latex) %(file-line-error) %(extraopts) %(output-dir) %S%(PDFout)")
  )
 image-types '(bmp svg webp png gif tiff jpeg xpm xbm pbm)
 preview-image-type 'png
 preview-image-creators '((dvipng (open preview-gs-open
preview-dvipng-process-setup)
  (place preview-gs-place) (close preview-dvipng-close))
 (png (open preview-gs-open) (place preview-gs-place)
  (close preview-gs-close))
 (jpeg (open preview-gs-open) (place preview-gs-place)
  (close preview-gs-close))
 (pnm (open preview-gs-open) (place preview-gs-place)
  (close preview-gs-close))
 (tiff (open preview-gs-open) (place preview-gs-place)
  (close preview-gs-close))
 )
 preview-dvipng-image-type 'png
 preview-dvipng-command "dvipng -picky -noghostscript %d -o
%m/prev%%03d.png"
 preview-pdf2dsc-command "pdf2dsc %(O?pdf) %m/preview.dsc"
 preview-gs-command
"c:/Users/johng/AppData/Local/Programs/MiKTeX/miktex/bin/x64/rungs.exe"
 preview-gs-options '("-q" "-dDELAYSAFER" "-dNOPAUSE" "-DNOPLATFONTS"
"-dPrinted"
 "-dTextAlphaBits=4" "-dGraphicsAlphaBits=4")
 preview-gs-image-type-alist '((png png "-sDEVICE=png16m")
  (dvipng png "-sDEVICE=png16m")
  (jpeg jpeg "-sDEVICE=jpeg") (pnm pbm "-sDEVICE=pnmraw")
  (tiff tiff "-sDEVICE=tiff12nc"))
 preview-fast-conversion t
 preview-prefer-TeX-bb nil
 preview-dvips-command "dvips -Pwww -i -E %d -o %m/preview.000"
 preview-fast-dvips-command "dvips -Pwww %d -o %m/preview.ps"
 preview-scale-function 'preview-scale-from-face
 preview-LaTeX-command '("%`%l
\"\\nonstopmode\\nofiles\\PassOptionsToPackage{"
("," . preview-required-option-list)
"}{preview}\\AtBeginDocument{\\ifx\\ifPreview\\undefined"
preview-default-preamble
"\\fi}\"%' \"\\detokenize{\" %(t-filename-only) \"}\"")
 preview-required-option-list '("active" "tightpage" "auctex"
(preview-preserve-counters "counters"))
 preview-preserve-counters nil
 preview-default-option-list '("displaymath" "floats" "graphics" "textmath"
"sections"
  "footnotes")
 preview-default-preamble '("\\RequirePackage[" ("," .
preview-default-option-list)
"]{preview}[2004/11/05]")
 preview-LaTeX-command-replacements nil
 preview-dump-replacements '(preview-LaTeX-command-replacements
("\\`\\([^ ]+\\)\\(?: +\\(?:\\(--?kanji[= ][^
]+\\)\\|\\(--?output-directory[= ][^ ]+\\)\\|-\\(?:[^
\\\"]\\|\\\\.\\|\"[^\"]*\"\\)*\\)\\)*\\(.*\\)\\'" "\\1 -ini \\2 \\3
-interaction=nonstopmode \"&\\1\" " preview-format-name ".ini \\4")
)
 preview-undump-replacements '(("\\`\\([^ ]+\\)\\(?: +\\(?:\\(--?kanji[=
][^ ]+\\)\\|\\(--?output-directory[= ][^ ]+\\)\\|-\\(?:[^
\\\"]\\|\\\\.\\|\"[^\"]*\"\\)*\\)\\)*.* \"\\\\input\" \"\\\\detokenize{\"
\\(.*\\) \"}\"\\'" "\\1 \\2 \\3 -interaction=nonstopmode -file-line-error "
preview-format-name " \"/AUCTEXINPUT{\" \\4 \"}\"")
  )
 preview-auto-cache-preamble 'ask
 preview-TeX-style-dir "c:/Users/johng/.emacs.d/elpa/auctex-13.2.1/latex"
 )

Output from running
`c:/Users/johng/AppData/Local/Programs/MiKTeX/miktex/bin/x64/rungs.exe -h':
MiKTeX GPL Ghostscript 9.25 (2018-09-13)
Copyright (C) 2018 Artifex Software, Inc.  All rights reserved.
Usage: gs [switches] [file1.ps file2.ps ...]
Most frequently used switches: (you can use # in place of =)
 -dNOPAUSE           no pause after page   | -q       `quiet', fewer
messages
 -g<width>x<height>  page size in pixels   | -r<res>  pixels/inch resolution
 -sDEVICE=<devname>  select device         | -dBATCH  exit after last file
 -sOutputFile=<file> select output file: - for stdout, |command for pipe,
                                         embed %d or %ld for page #
Input formats: PostScript PostScriptLevel1 PostScriptLevel2
PostScriptLevel3 PDF
Default output device: display
Available devices:
   bbox bit bitcmyk bitrgb bitrgbtags bj10e bj200 bjc600 bjc800 bmp16 bmp16m
   bmp256 bmp32b bmpgray bmpmono bmpsep1 bmpsep8 cdeskjet cdj550 cdjcolor
   cdjmono declj250 deskjet devicen display djet500 djet500c eps2write
   eps9high eps9mid epson epsonc fpng gprf ibmpro ijs ink_cov inkcov
   jetp3852 jpeg jpegcmyk jpeggray laserjet lbp8 lj250 ljet2p ljet3 ljet3d
   ljet4 ljet4d ljetplus m8510 mswinpr2 necp6 nullpage pam pamcmyk32
   pamcmyk4 pbm pbmraw pclm pcx16 pcx24b pcx256 pcxcmyk pcxgray pcxmono
   pdfimage24 pdfimage32 pdfimage8 pdfwrite pgm pgmraw pgnm pgnmraw pj pjxl
   pjxl300 pkmraw plan planc plang plank planm planr plib plibc plibg plibk
   plibm png16 png16m png256 pngalpha pnggray pngmono pngmonod pnm pnmcmyk
   pnmraw ppm ppmraw ps2write psdcmyk psdcmykog psdrgb pxlcolor pxlmono
   r4081 spotcmyk st800 stcolor t4693d2 t4693d4 t4693d8 tek4696 tiff12nc
   tiff24nc tiff32nc tiff48nc tiff64nc tiffcrle tiffg3 tiffg32d tiffg4
   tiffgray tifflzw tiffpack tiffscaled tiffscaled24 tiffscaled32
   tiffscaled4 tiffscaled8 tiffsep tiffsep1 txtwrite uniprint xpswrite
Search path:
   C:/Users/johng/AppData/Local/Programs/MiKTeX/ghostscript/base ;
   C:/Users/johng/AppData/Local/Programs/MiKTeX/fonts ;
   %rom%Resource/Init/ ; %rom%lib/ ; c:/gs/gs9.25/Resource/Init ;
   c:/gs/gs9.25/lib ; c:/gs/gs9.25/Resource/Font ; c:/gs/fonts
Initialization files are compiled into the executable.
For more information, see c:/gs/gs9.25/doc/Use.htm.
Please report bugs to bugs.ghostscript.com.