2

Update

Per the advice of a user on stack overflow, https://stackoverflow.com/questions/77449192/issue-with-asymptote-execution-in-latex-failed-to-create-directory-asy, I upgraded all of my MikTeX packages, and moved all of my LaTeX-related files to one folder. Namely, the %USERPROFILE% directory because that's the starter directory for Asymptote. The asy command is still not working for the files. I even tried prebuilding a .asy folder is my %USERPROFILE% directory and putting the .asy files there and even then it still won't work. Maybe it's because Windows won't let you end a folder with a (period/dot/"."). I also tried running asy -f pdf asymptote-latex.asy

Here is the error message for when it's in the %USERPROFILE% directory:

C:\Users\twill>asy C:\Users\twill\asymptote-latex-1.asy
failed to create directory /.asy.
Error: /undefined in .setfillconstantalpha
Operand stack:
   1
Execution stack:
   %interp_exit   .runexec2   --nostringval--   --nostringval--   --nostringval--   2   %stopped_push   --nostringval--   --nostringval--   --nostringval--   false   1   %stopped_push   2015   1   3   %oparray_pop   2014   1   3   %oparray_pop   --nostringval--   1998   1   3   %oparray_pop   1884   1   3   %oparray_pop   --nostringval--   %errorexec_pop   .runexec2   --nostringval--   --nostringval--   --nostringval--   2   %stopped_push   --nostringval--
Dictionary stack:
   --dict:980/1684(ro)(G)--   --dict:0/20(G)--   --dict:82/200(L)--
Current allocation mode is local
Current file position is 602
MiKTeX GPL Ghostscript 9.25: Unrecoverable error, exit code 1
  _shipout(prefix,f,currentpatterns,format,wait,view,t);
          ^
C:\Users\twill\AppData\Local\Programs\MiKTeX/asymptote/plain_shipout.asy: 116.11: runtime: shipout failed

Here is the error message for when its in the prebuilt .asy folder:

C:\Users\twill>asy C:\Users\twill\.asy\asymptote-latex-1.asy
failed to create directory /.asy.
Error: /undefined in .setfillconstantalpha
Operand stack:
   1
Execution stack:
   %interp_exit   .runexec2   --nostringval--   --nostringval--   --nostringval--   2   %stopped_push   --nostringval--   --nostringval--   --nostringval--   false   1   %stopped_push   2015   1   3   %oparray_pop   2014   1   3   %oparray_pop   --nostringval--   1998   1   3   %oparray_pop   1884   1   3   %oparray_pop   --nostringval--   %errorexec_pop   .runexec2   --nostringval--   --nostringval--   --nostringval--   2   %stopped_push   --nostringval--
Dictionary stack:
   --dict:980/1684(ro)(G)--   --dict:0/20(G)--   --dict:82/200(L)--
Current allocation mode is local
Current file position is 602
MiKTeX GPL Ghostscript 9.25: Unrecoverable error, exit code 1
  _shipout(prefix,f,currentpatterns,format,wait,view,t);
          ^
C:\Users\twill\AppData\Local\Programs\MiKTeX/asymptote/plain_shipout.asy: 116.11: runtime: shipout failed

Main Content

This question further explores an issue that was previously addressed in one of my earlier inquiries: Asymptote Error: Missing PDF File during Compilation

I am encountering a peculiar issue when working with my LaTeX document that includes Asymptote code. The LaTeX compilation appears to generate the necessary .asy files, but when I attempt to execute Asymptote separately on these files, I encounter difficulties.

Here's the setup and the steps I have taken:

  • I am using a Windows operating system.
  • I have successfully installed LaTeX, Asymptote, and Ghostscript, and have verified that all three are included in my system's PATH.
  • I use the -shell-escape option when compiling my LaTeX document.

The LaTeX compilation log suggests that the Asymptote code is being executed correctly, as I observe the generation of a PDF file (asymptote-latex-1.pdf). However, when I try to run Asymptote manually on the generated .asy files, it does not work.

I have tried using the following commands to run Asymptote:

  1. asy "C:\Users\twill\OneDrive\Desktop\ASYMPTOTE\output-directory\asymptote-latex-1.asy"
  2. asy C:\Users\twill\asymptote-latex-*.asy

Despite this, I encounter issues, and Asymptote does not seem to process the files correctly. The specific error message I am facing is: failed to create directory /.asy.. The log of the LaTeX compilation does not provide any error messages related to Asymptote.

Has anyone encountered a similar issue where the LaTeX compilation generates .asy files, but Asymptote execution on these files fails? I would greatly appreciate any insights, troubleshooting steps, or solutions to ensure that the Asymptote code processes the .asy files correctly.

Thank you for your assistance.

MWE: (Credit: 'filename-1.pdf' not found Asymptote)

\documentclass{article}
\usepackage{graphicx}
\usepackage{asymptote}
\begin{document}
\begin{asy}
size(200);
pen[] p={red,green,blue,magenta};
path g=(0,0){dir(45)}..(1,0)..(1,1)..(0,1)..cycle;
tensorshade(g,p);
dot(g);
\end{asy}
\end{document}

log:

This is pdfTeX, Version 3.141592653-2.6-1.40.25 (MiKTeX 23.5) (preloaded format=pdflatex 2023.8.22)  6 NOV 2023 10:25
entering extended mode
 restricted \write18 enabled.
 %&-line parsing enabled.
**C:/Users/twill/OneDrive/Desktop/ASYMPTOTE/asymptote-latex.tex
(C:/Users/twill/OneDrive/Desktop/ASYMPTOTE/asymptote-latex.tex
LaTeX2e <2023-06-01> patch level 1
L3 programming layer <2023-08-11>
(C:\Users\twill\AppData\Local\Programs\MiKTeX\tex/latex/base\article.cls
Document Class: article 2023/05/17 v1.4n Standard LaTeX document class
(C:\Users\twill\AppData\Local\Programs\MiKTeX\tex/latex/base\size10.clo
File: size10.clo 2023/05/17 v1.4n Standard LaTeX file (size option)
)
\c@part=\count185
\c@section=\count186
\c@subsection=\count187
\c@subsubsection=\count188
\c@paragraph=\count189
\c@subparagraph=\count190
\c@figure=\count191
\c@table=\count192
\abovecaptionskip=\skip48
\belowcaptionskip=\skip49
\bibindent=\dimen140
)
(C:\Users\twill\AppData\Local\Programs\MiKTeX\tex/latex/graphics\graphicx.sty
Package: graphicx 2021/09/16 v1.2d Enhanced LaTeX Graphics (DPC,SPQR)

(C:\Users\twill\AppData\Local\Programs\MiKTeX\tex/latex/graphics\keyval.sty
Package: keyval 2022/05/29 v1.15 key=value parser (DPC)
\KV@toks@=\toks17
)
(C:\Users\twill\AppData\Local\Programs\MiKTeX\tex/latex/graphics\graphics.sty
Package: graphics 2022/03/10 v1.4e Standard LaTeX Graphics (DPC,SPQR)

(C:\Users\twill\AppData\Local\Programs\MiKTeX\tex/latex/graphics\trig.sty
Package: trig 2021/08/11 v1.11 sin cos tan (DPC)
)
(C:\Users\twill\AppData\Local\Programs\MiKTeX\tex/latex/graphics-cfg\graphics.c
fg
File: graphics.cfg 2016/06/04 v1.11 sample graphics configuration
)
Package graphics Info: Driver file: pdftex.def on input line 107.

(C:\Users\twill\AppData\Local\Programs\MiKTeX\tex/latex/graphics-def\pdftex.def
File: pdftex.def 2022/09/22 v1.2b Graphics/color driver for pdftex
))
\Gin@req@height=\dimen141
\Gin@req@width=\dimen142
)
(C:\Users\twill\AppData\Local\Programs\MiKTeX\tex/latex/asymptote\asymptote.sty
Package: asymptote 2021/12/29 v1.37 Asymptote style file for LaTeX
(asymptote-latex.pre)
\ASYbox=\box51
\ASYdimen=\dimen143
\c@asy=\count193
\AsyStream=\write3
\AsyPreStream=\write4

(C:\Users\twill\AppData\Local\Programs\MiKTeX\tex/latex/base\ifthen.sty
Package: ifthen 2022/04/13 v1.1d Standard LaTeX ifthen package (DPC)
)
(C:\Users\twill\AppData\Local\Programs\MiKTeX\tex/generic/iftex\ifpdf.sty
Package: ifpdf 2019/10/25 v3.4 ifpdf legacy package. Use iftex instead.

(C:\Users\twill\AppData\Local\Programs\MiKTeX\tex/generic/iftex\iftex.sty
Package: iftex 2022/02/03 v1.0f TeX engine tests
))
(C:\Users\twill\AppData\Local\Programs\MiKTeX\tex/generic/iftex\ifxetex.sty
Package: ifxetex 2019/10/25 v0.7 ifxetex legacy package. Use iftex instead.
)
(C:\Users\twill\AppData\Local\Programs\MiKTeX\tex/generic/catchfile\catchfile.s
ty
Package: catchfile 2019/12/09 v1.8 Catch the contents of a file (HO)

(C:\Users\twill\AppData\Local\Programs\MiKTeX\tex/generic/infwarerr\infwarerr.s
ty
Package: infwarerr 2019/12/03 v1.5 Providing info/warning/error messages (HO)
)
(C:\Users\twill\AppData\Local\Programs\MiKTeX\tex/generic/ltxcmds\ltxcmds.sty
Package: ltxcmds 2020-05-10 v1.25 LaTeX kernel commands for general use (HO)
)
(C:\Users\twill\AppData\Local\Programs\MiKTeX\tex/generic/etexcmds\etexcmds.sty
Package: etexcmds 2019/12/15 v1.7 Avoid name clashes with e-TeX commands (HO)
))
\openout4 = `asymptote-latex.pre'.

)
(C:\Users\twill\AppData\Local\Programs\MiKTeX\tex/latex/l3backend\l3backend-pdf
tex.def
File: l3backend-pdftex.def 2023-04-19 L3 backend support: PDF output (pdfTeX)
\l__color_backend_stack_int=\count194
\l__pdf_internal_box=\box52
) (asymptote-latex.aux)
\openout1 = `asymptote-latex.aux'.

LaTeX Font Info:    Checking defaults for OML/cmm/m/it on input line 4.
LaTeX Font Info:    ... okay on input line 4.
LaTeX Font Info:    Checking defaults for OMS/cmsy/m/n on input line 4.
LaTeX Font Info:    ... okay on input line 4.
LaTeX Font Info:    Checking defaults for OT1/cmr/m/n on input line 4.
LaTeX Font Info:    ... okay on input line 4.
LaTeX Font Info:    Checking defaults for T1/cmr/m/n on input line 4.
LaTeX Font Info:    ... okay on input line 4.
LaTeX Font Info:    Checking defaults for TS1/cmr/m/n on input line 4.
LaTeX Font Info:    ... okay on input line 4.
LaTeX Font Info:    Checking defaults for OMX/cmex/m/n on input line 4.
LaTeX Font Info:    ... okay on input line 4.
LaTeX Font Info:    Checking defaults for U/cmr/m/n on input line 4.
LaTeX Font Info:    ... okay on input line 4.

(C:\Users\twill\AppData\Local\Programs\MiKTeX\tex/context/base/mkii\supp-pdf.mk
ii
[Loading MPS to PDF converter (version 2006.09.02).]
\scratchcounter=\count195
\scratchdimen=\dimen144
\scratchbox=\box53
\nofMPsegments=\count196
\nofMParguments=\count197
\everyMPshowfont=\toks18
\MPscratchCnt=\count198
\MPscratchDim=\dimen145
\MPnumerator=\count199
\makeMPintoPDFobject=\count266
\everyMPtoPDFconversion=\toks19
)
(C:\Users\twill\AppData\Local\Programs\MiKTeX\tex/latex/epstopdf-pkg\epstopdf-b
ase.sty
Package: epstopdf-base 2020-01-24 v2.11 Base part for package epstopdf
Package epstopdf-base Info: Redefining graphics rule for `.eps' on input line 4
85.

(C:\Users\twill\AppData\Local\Programs\MiKTeX\tex/latex/00miktex\epstopdf-sys.c
fg
File: epstopdf-sys.cfg 2021/03/18 v2.0 Configuration of epstopdf for MiKTeX
))
\openout3 = `asymptote-latex-1.asy'.

<asymptote-latex-1.pdf, id=1, 200.75pt x 131.06967pt>
File: asymptote-latex-1.pdf Graphic file (type pdf)
<use asymptote-latex-1.pdf>
Package pdftex.def Info: asymptote-latex-1.pdf  used on input line 11.
(pdftex.def)             Requested size: 200.7495pt x 131.06934pt.
 [1

{C:/Users/twill/AppData/Local/MiKTeX/fonts/map/pdftex/pdftex.map} <./asymptote-
latex-1.pdf>] (asymptote-latex.aux)
 ***********
LaTeX2e <2023-06-01> patch level 1
L3 programming layer <2023-08-11>
 ***********
 ) 
Here is how much of TeX's memory you used:
 1800 strings out of 475503
 31543 string characters out of 5761834
 1916248 words of memory out of 12000000
 23078 multiletter control sequences out of 15000+600000
 558069 words of font info for 36 fonts, out of 8000000 for 9000
 1141 hyphenation exceptions out of 8191
 62i,5n,65p,256b,139s stack positions out of 10000i,1000n,20000p,200000b,200000s
<C:/Users/twill/AppData/Local/Programs/MiKTeX/fonts/type1/public/amsfonts/cm/
cmr10.pfb>
Output written on asymptote-latex.pdf (1 page, 9798 bytes).
PDF statistics:
 13 PDF objects out of 1000 (max. 8388607)
 0 named destinations out of 1000 (max. 500000)
 6 words of extra memory for PDF output out of 10000 (max. 10000000)

1 Answer 1

2

With help from a professor at my university, the issue has been resolved!

Here are the steps I took (for future self reference and for others struggling with the same thing).

Step 1: Uninstall ghostscript and miktex

Step 2: install miktex and the latest ghostscript.

Step 3: global search for mgs (in the MikTeX directory) and change its same to something else (I used mgstemp)

Step 4: global search for gswin64.exe (in the ghostscript directory) and change its name to mgs

Step 5: any time you update MikTeX, it will create a new mgs file (in the MikTex Directory!!!!!!). You need to change this to another name every time.

Step 6: The commands pdflatex test then asy test-1.asy then pdflatex test will produce your document!

You must log in to answer this question.