Subject: bug#35363: 12.1.2; Generation of previews fails under Windows 10

From: Bernt Guldbrandtsen <[email-masked]>
Date: Sun, 21 Apr 2019 17:25:50 +0000

Hello!

Recently, generating previews under AUCTeX started to fail. Until some months ago,
I had a working setup.  The OS is Windows 10 (updated). A minimal working
example is shown below. Running LaTeX on _region_.tex works and the PDF
file produced contains the expected content. However, running gs fails
with no diagnostics.

The machine has MiKTeX's mgs and "normal" gswin64 installed. At the
Cygwin command prompt both can run the conversion successfully. MiKTeX
(64 bit version) is updated and has mgs version 9.25. Ghostscript (64
bit version) is updated and is version 9.27.

In Emacs,

   M-! mgs
   
and

   M-! gswin64
   
find mgs and gswin64 respectively as expected.

A command such as

  mgs -dDELAYSAFER -sDEVICE=png16m -dPrinter -dNOPLATFONTS
    -dTextAlphaBits=4 -dGraphicsAlphaBits=4 -o 'pic-%d.png'
    _region_.pdf

produces the expected png output file.

It looks like mgs fails to run at all despite that Emacs is able
to find mgs.exe correctly.

Any pointers?

Best regards,

Bernt

Minimal example:
----
\documentclass{article}

\begin{document}

Here is a test.
\begin{displaymath}
  \alpha^2=\sqrt{\beta}\gamma^2
\end{displaymath}

\end{document}

%%% Local Variables:
%%% mode: latex
%%% TeX-master: t
%%% End:
----

Emacs  : GNU Emacs 25.3.1 (x86_64-w64-mingw32)
 of 2017-09-12
Package: 12.1.2

Run buffer contents:

Running `Preview-LaTeX' on `test' with ``pdflatex -ini  -interaction=nonstopmode "&pdflatex" "prv_test".ini  "\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{" "test.tex" "}}"''
This is pdfTeX, Version 3.14159265-2.6-1.40.20 (MiKTeX 2.9.7000 64-bit) (INITEX)
entering extended mode
(prv_test.ini
LaTeX2e <2018-12-01>

("C:\Users\au154761\AppData\Local\Programs\MiKTeX 2.9\tex/latex/carlisle\mylate
x.ltx")
("C:\Users\au154761\AppData\Local\Programs\MiKTeX 2.9\tex/latex/tools\.tex"
File ignored))
No auxiliary output files.

(test.tex
("C:\Users\au154761\AppData\Local\Programs\MiKTeX 2.9\tex/latex/base\article.cl
s"
Document Class: article 2018/09/03 v1.4i Standard LaTeX document class
("C:\Users\au154761\AppData\Local\Programs\MiKTeX 2.9\tex/latex/base\size10.clo
")) )
Beginning to dump on file prv_test.fmt
 (preloaded format=prv_test 2019.4.21)
5823 strings of total length 84889
54972 memory locations dumped; current usage is 219&53497
4012 multiletter control sequences
\font\nullfont=nullfont
\font\OMX/cmex/m/n/5=cmex10
\font\tenln=line10
\font\tenlnw=linew10
\font\tencirc=lcircle10
\font\tencircw=lcirclew10
\font\OT1/cmr/m/n/5=cmr5
\font\OT1/cmr/m/n/7=cmr7
\font\OT1/cmr/m/n/10=cmr10
\font\OML/cmm/m/it/5=cmmi5
\font\OML/cmm/m/it/7=cmmi7
\font\OML/cmm/m/it/10=cmmi10
\font\OMS/cmsy/m/n/5=cmsy5
\font\OMS/cmsy/m/n/7=cmsy7
\font\OMS/cmsy/m/n/10=cmsy10
\font\OT1/cmr/m/n/12=cmr12
\font\OT1/cmr/m/n/8=cmr8
\font\OT1/cmr/bx/n/10=cmbx10
\font\OT1/cmr/bx/it/10=cmbxti10
\font\OT1/cmr/m/it/10=cmti10
\font\OT1/cmtt/m/n/10=cmtt10
\font\OT1/cmss/m/n/10=cmss10
5716 words of font info for 21 preloaded fonts
36 hyphenation exceptions
Hyphenation trie of length 105938 has 2723 ops out of 35111
  377 for language 16
  224 for language 15
  23 for language 13
  475 for language 12
  235 for language 11
  201 for language 10
  478 for language 9
  207 for language 8
  40 for language 7
  89 for language 6
  60 for language 4
  36 for language 2
  97 for language 1
  181 for language 0
0 words of pdfTeX memory
0 indirect objects
No pages of output.
Transcript written on prv_test.log.

TeX Output finished at Sun Apr 21 18:59:13
Running `Preview-LaTeX' on `~/test8/_region_' with ``pdflatex  -interaction=nonstopmode -file-line-error "&prv_test" "/AUCTEXINPUT{" "_region_.tex" "}"''
This is pdfTeX, Version 3.14159265-2.6-1.40.20 (MiKTeX 2.9.7000 64-bit)
entering extended mode
LaTeX2e <2018-12-01>
CUSTOMISED FORMAT. Preloaded files:
        .
     test.tex 
 article.cls    2018/09/03 v1.4i Standard LaTeX document class
  size10.clo    2018/09/03 v1.4i Standard LaTeX file (size option)
        .
(_region_.tex (_region_.aux)
(c:/cygwin64/home/au154761/.emacs.d/elpa/auctex-12.1.2/latex\preview.sty
("C:\Users\au154761\AppData\Local\Programs\MiKTeX 2.9\tex/generic/luatex85\luat
ex85.sty")
(c:/cygwin64/home/au154761/.emacs.d/elpa/auctex-12.1.2/latex\prtightpage.def)
(c:/cygwin64/home/au154761/.emacs.d/elpa/auctex-12.1.2/latex\prauctex.def
No auxiliary output files.

(c:/cygwin64/home/au154761/.emacs.d/elpa/auctex-12.1.2/latex\prauctex.cfg))
(c:/cygwin64/home/au154761/.emacs.d/elpa/auctex-12.1.2/latex\prfootnotes.def)
Preview: Fontsize 10pt
Preview: PDFoutput 1
)  !name(test.tex) !offset(-3) 
_region_.tex:9: Preview: Snippet 1 started
Preview: Tightpage -32891 -32891 32891 32891
_region_.tex:11: Preview: Snippet 1 ended.(1609687+0x22609920)
[1{C:/Users/au154761/AppData/Local/MiKTeX/2.9/pdftex/config/pdftex.map}] )
(see the transcript file for additional information)<C:/Users/au154761/AppData/
Local/Programs/MiKTeX 2.9/fonts/type1/public/amsfonts/cm/cmex10.pfb><C:/Users/a
u154761/AppData/Local/Programs/MiKTeX 2.9/fonts/type1/public/amsfonts/cm/cmmi10
.pfb><C:/Users/au154761/AppData/Local/Programs/MiKTeX 2.9/fonts/type1/public/am
sfonts/cm/cmr10.pfb><C:/Users/au154761/AppData/Local/Programs/MiKTeX 2.9/fonts/
type1/public/amsfonts/cm/cmr7.pfb>
Output written on _region_.pdf (1 page, 31451 bytes).
Transcript written on _region_.log.

TeX Output exited as expected with code 1 at Sun Apr 21 18:59:13
LaTeX: LaTeX found no preview images

current state:
==============
(setq
 AUCTeX-version "12.1.2"
 LaTeX-command-style '((""
			"%(PDF)%(latex) %(file-line-error) %(extraopts) %S%(PDFout)")
		       )
 image-types '(svg 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 %s.pdf %m/preview.dsc"
 preview-gs-command "c:/Users/au154761/AppData/Local/Programs/MiKTeX 2.9/miktex/bin/x64/mgs.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 0.8
 preview-LaTeX-command '("%`%l \"\\nonstopmode\\nofiles\\PassOptionsToPackage{"
			 ("," . preview-required-option-list)
			 "}{preview}\\AtBeginDocument{\\ifx\\ifPreview\\undefined" preview-default-preamble "\\fi}\"%' \"{\\detokenize{\" %t \"}}\"")
 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[= ][^ ]+\\)\\|-\\(?:[^ \\\"]\\|\\\\.\\|\"[^\"]*\"\\)*\\)\\)*\\(.*\\)\\'" "\\1 -ini \\2 -interaction=nonstopmode \"&\\1\" " preview-format-name ".ini \\3")
			     )
 preview-undump-replacements '(("\\`\\([^ ]+\\)\\(?: +\\(?:\\(--?kanji[= ][^ ]+\\)\\|-\\(?:[^ \\\"]\\|\\\\.\\|\"[^\"]*\"\\)*\\)\\)*.* \"\\\\input\" \"{\\\\detokenize{\" \\(.*\\) \"}}\"\\'" "\\1 \\2 -interaction=nonstopmode -file-line-error " preview-format-name " \"/AUCTEXINPUT{\" \\3 \"}\"")
			       )
 preview-auto-cache-preamble t
 preview-TeX-style-dir "c:/cygwin64/home/au154761/.emacs.d/elpa/auctex-12.1.2/latex"
 )

Output from running `c:/Users/au154761/AppData/Local/Programs/MiKTeX 2.9/miktex/bin/x64/mgs.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:
   %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.