vectorgraphics / asymptote

2D & 3D TeX-Aware Vector Graphics Language
https://asymptote.sourceforge.io/
GNU General Public License v3.0
533 stars 89 forks source link

Shipout to svg not working on MacOS #391

Closed riyazahuja closed 9 months ago

riyazahuja commented 11 months ago

Running on 2023 M2 Pro Macbook pro, running MacOS Ventura 13.2.1

Hello, I'm unable to export any of my asymptote diagrams as an svg file, although I was able to easily on my old windows machine. This issue has been repeated on 3 different macs, with the same problems appearing every time. The following log illustrates the process I went through to produce these errors on a brand new machine with a fresh install of MacOS Ventura 13.2.1:

  1. Installed MacTeX.pkg from tug.org/mactex/mactex-download.html and installed it on my machine. In install options, I selected customize and selected all options (ghostscript 10.00, ghostscript dynamic library, GUI applications, TEXLive 2023). Note that which asy returns /Library/TeX/texbin/tex

  2. Then, in Desktop/Asy-test/ I made a file called test.asy, and opened it in VSCode (also downloaded the Asymptote extension on VSCode). The initial contents of test.asy were:

    Settings.outformat = “svg”;
    unitsize(fontsize());
    Pair a = (0,0);
    Pair b = (1,3);
    Pair c = (2,4);
    Pair d = (-1,1);
    draw(a–b–c–d–cycle);

    The output of asy test.asy (after cding into the correct directory) was:

    Processing of PostScript specials is disabled (Ghostscript not found)
    WARNING: 1 PostScript special ignored. The resulting SVG might look wrong.

    The svg file was created and was correct. However, in previous attempts of recreating this problem, the svg output did in fact have issues when labels were included (especially if they were rotated).

  3. Now, I changed the contents of test.asy to:

    settings.outformat = “svg”;
    unitsize(fontsize());
    draw(unitcircle());

    The output of asy test.asy was:

    Processing of PostScript specials is disabled (Ghostscript not found)
    XML error: error in path data: number expected (premature end of data)
    _shipout(prefix,f,currentpatterns,format,wait,view,t);
              ^
    /usr/local/texlive/2023/texmf-dist/asymptote/plain_shipout.asy: 116.11: runtime:
    Shipout failed

    No svg output was created.

  4. I ran the first version of test.asy (with a,b,c,d) again, and it now also had the XML error + ghostscript error and did not create any output.

  5. Now, attempting to fix the ghostscript error, I ran dvisvgm -V1, noting that there was no ghostscript in the output. which gs returns /usr/local/bin/gs and I decided to homebrew install ghostscript. I ran brew install gs and now which gs returns /opt/homebrew/bin/gs.

  6. I ran export LIBGS=/opt/homebrew/lib/libgs.dylib and now running dvisvgm -V1 shows ghostscript 10.1.2 Also, running asy test.asy now still has the XML error, but no ghostscript error.

  7. Attempting to fix the XML error, I brew install asymptote, and now which asy returns /opt/homebrew/bin/asy, and running /opt/homebrew/bin/asy test.asy returns:

    XML error: error in path data: number expected (premature end of data)
    _shipout(prefix,f,currentpatterns,format,wait,view,t);
           ^
    /opt/homebrew/Cellar/asymptote/2.86/share/asymptote/plain_shipout.asy: 116.11: runtime: shipout failed

All in all, I have no idea how to fix this XML issue, and why it only started after the second time ever running asy test.asy. I am quite certain that the contents of test.asy were not an issue, but perhaps something changed behind the scenes after the first time running asy? I'm really not sure, so any help would be appreciated. Thanks!

johncbowman commented 9 months ago

This isn't an Asymptote issue (see https://bytemeta.vip/repo/mgieseki/dvisvgm/issues/240) but in any case I will implement the workaround mentioned there.