Menu

Why is gs not found?

Help
mauvia
2024-08-27
2024-09-03
  • mauvia

    mauvia - 2024-08-27

    I am on MacOS Sonoma and Asymptote 2.91

    I do not understand why compiling a certain .asy file with options

    -f html

    I get

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

    I have file:

    /Users/maurizio/.asy/config.asy

    with content:

    import settings;
    gs="/opt/homebrew/Cellar/ghostscript/10.03.1/bin/gs";
    

    and I have gs with the following path

    /opt/homebrew/Cellar/ghostscript/10.03.1/bin/gs

    Why gs is not found?
    What could be wrong?

    Thanks
    Maurizio

     
  • John Bowman

    John Bowman - 2024-08-28

    dvisvgm needs the ghostscript library libgs.so or libgs.a; see
    https://dvisvgm.de/FAQ/

     
    • mauvia

      mauvia - 2024-08-29

      Thanks!!!

      However my situation is still not clear, and perhaps of interest to someone else.

      I searched for libgs.so (which on MacOs, is named libgs.dylib, as I learned) and I found it:

      /System/Volumes/Data/opt/homebrew/lib/libgs.dylib
      /System/Volumes/Data/opt/homebrew/Cellar/ghostscript/10.03.1/lib/libgs.dylib
      /opt/homebrew/lib/libgs.dylib
      /opt/homebrew/Cellar/ghostscript/10.03.1/lib/libgs.dylib
      

      I also added a path to it:

      LIBGS="/opt/homebrew/lib/libgs.dylib"

      just to make sure. Thus, I assume that "libgs.dylib" is known to the compiler.

      However, please consider the following .asy file (sorry for its length):

      ////////////////////////////////////////////
      import three;
      import tube;
      import graph3;
      
      currentpicture=new picture;
      unitsize(10cm);
      currentlight=White;
      
      ///////////////////////////////////////////////////
      ///////////////////////////////////////////////////
      //Routine created by me (it usually works, in 2D pictures, and it worked here 2/3 years 
      //ago)
      
      void drawshifted(picture pic=currentpicture, Label L="", path g, pair true_shift,
      pen p=currentpen,  arrowbar arrow=None, arrowbar bar=None, margin
      margin=NoMargin, marker marker=nomarker)
      {
      transform T=shift(true_shift);
      pic.add(new void (frame f, transform t) {
      picture opic;
      path G=T*t*g;
      draw(opic,L,G,p,arrow,bar,margin,marker);
      add(f,opic.fit());
      });
      pic.addBox(min(g),max(g),T*min(p),T*max(p));
      }
      
      ///////////////////////////////////////////////////
      ///////////////////////////////////////////////////
      
      real R=2;
      triple P(real t){return (R*Cos(t),R*Sin(t),0);}
      path3 centercurve=shift(-R,0,0)*graph(P,340,360);
      path centercurveshifted=project(centercurve);
      
      draw(surface(tube(centercurve,scale(0.01)*unitcircle)),lightgray);
      draw(rotate(90,X)*(scale3(0.01)*unitdisk),gray);
      
      
      draw(centercurve,linewidth(.2));
      
      triple pO=(0,0,0);
      
      real u=.06*R;
      real r=0.02;
      
      triple N=dir(110,70);
      
      path3 ring=circle(pO+u/2*dir(110,70),r,dir(110,70));
      
      draw(ring,Arrow3(3));
      
      draw(Label("$\mathbf{T}(s)$",EndPoint),pO--pO+u*dir(50,120),linewidth(1),Arrow3(3));
      draw(Label("$\mathbf{M}(s)$",EndPoint),pO--pO+u*dir(110,70),linewidth(1),Arrow3(3));
      
      //OFFENDING LINE
      //drawshifted(Label("$s$",LeftSide),centercurveshifted,3mm*NE,linewidth(.2),Arrow(3));
      ///////////////////
      
      shipout("My3DPicture");
      
      //////////////////////////////////////
      //////////////////////////////////////
      

      Everything is ok here (both with "-f pdf -render 0" option, or "-f html" option), with no complains about "ghostscript cannot be found" and similar, if I DO NOT UNCOMMENT the final "offending line".

      BUT if I uncomment the "offending line", at the end, then I have issues (wrong pdf or complains about "ghostscript cannot be found" if I use -f html option...)

      Of course that line makes use of my routine "drawshifted", created by me years ago. I have to make clear that in 2D pictures my routine still works well (for my usage, at least)

      More interestingly, and this is a problem I had on other occasions, this source file was created by me 2/3 years ago and I am sure that at that time IT WORKED, including the "offending line". I still have the nice pdf produced by it.

      It is not the first time that for some "complex" 3D pictures my 2/3 years (good) old source code will no longer work, or it will give me some problems.

      My other question (perhaps of more general interest) is:

      How much asymptote is really backward compatible?

      Thanks!!!

      Maurizio

       
  • John Bowman

    John Bowman - 2024-09-01

    You are trying to combine 2d and 3d graphics in a single file. Do you want to project everything to 2D? Otherwise how should 2d and 3D graphics be combined? If you delete the shipout line and turn on the -v option you will see that your example first generates the rendered 3D output and then immediately overwrites it with the 2D output you requested. The extra shipout does 2 additional shipouts to the file My3DPicture.eps.

    Asymptote is generally backwards compatible but in the interest of progress some documented incompatibilities have been introduced over the last two decades. For example, see the Release Notes for version 2.90, 2.10, 2.02, 1.89, 1.83, 1.50, 1.44, 1.43, 1.42, 1.17, 1.04, and 0.84. In your case, you were relying on undocumented behaviour of how 2D and 3D graphics generated by the same asy process should be handled; should they be output to different files?

     
    • mauvia

      mauvia - 2024-09-01

      Yes, basically I wanted to combine 2d and 3d output, in order to be able to use in some 3d context my macro "drawshifted" which is basically a 2d tool, but which I found useful in some 3d situation. I attach a picture which some years ago I was able to create in this way. The path with the $s$ clearly denotes the abscissa of the point where the tube ends. I got that by "drawing shifted" the path on which the tube is based. Now I am in the situtation in which I need to edit and slightly modify a bunch of pictures like that, but it seems my technique no longer works, and now I understand why. It is not clear to me if my "drawshifted" routine (which I find very useful in many many 2d pictures, where it works nicely) can be modified to some "drawshifted3d" (say) which could be applied in a 3D context. This is my problem.

      Thanks!

      Maurizio

      PS: I post again my drawshifted routine. I add that if I remember correctly this is a construction which is based on some examples in the Gallery (I think that at least one example was created as an anwser to a request of mine....).

      void drawshifted(picture pic=currentpicture, Label L="", path g, pair true_shift,
      pen p=currentpen,  arrowbar arrow=None, arrowbar bar=None, margin
      margin=NoMargin, marker marker=nomarker)
      {
      transform T=shift(true_shift);
      pic.add(new void (frame f, transform t) {
      picture opic;
      path G=T*t*g;
      draw(opic,L,G,p,arrow,bar,margin,marker);
      add(f,opic.fit());
      });
      pic.addBox(min(g),max(g),T*min(p),T*max(p));
      }
      
       
    • mauvia

      mauvia - 2024-09-01

      Now I realize something strange is happening here. I attached a pdf to my previous answer. The pdf I see and which I uploaded from my mac is different from the pdf I see if I download the attached picture and I look at it (with the same viewer). Indeed, I no longer see a part of it (I no longer see the tube but only the part with the 2d segment). How is that possible? I add that the pdf I have on my mac was sent to Springer and a book was printed (2 or 3 years ago) with that picture appearing on paper exactly as I see it on my Mac.

      Is this a pdf (adobe) problem, or something related with Asymptote? Or else?

      Thanks
      Maurizio

       
    • mauvia

      mauvia - 2024-09-01

      I attach a screenshot of the original pdf.

       
  • John Bowman

    John Bowman - 2024-09-03

    Here's how to draw a 3D version of that scene. I've attached the corresponding HTML output.

    import three;
    import tube;
    import graph3;
    
    currentpicture=new picture;
    
    unitsize(10cm);
    currentlight=White;
    
    real R=2;
    triple P(real t){return (R*Cos(t),R*Sin(t),0);}
    path3 centercurve=shift(-R,0,0)*graph(P,340,360);
    path centercurveshifted=project(centercurve);
    
    draw(surface(tube(centercurve,scale(0.01)*unitcircle)),lightgray);
    draw(rotate(90,X)*(scale3(0.01)*unitdisk),gray);
    
    
    draw(centercurve,linewidth(.2));
    
    triple pO=(0,0,0);
    
    real u=.06*R;
    real r=0.02;
    
    triple N=dir(110,70);
    
    path3 ring=circle(pO+u/2*dir(110,70),r,dir(110,70));
    
    draw(ring,Arrow3(3));
    
    draw(Label("$\mathbf{T}(s)$",EndPoint),pO--pO+u*dir(50,120),linewidth(1),Arrow3(3));
    draw(Label("$\mathbf{M}(s)$",EndPoint),pO--pO+u*dir(110,70),linewidth(1),Arrow3(3));
    
    triple v=perp(dir(centercurve,reltime(centercurve,0.5)));
    draw(Label("$s$",align=v),shift(0.02*v)*centercurve,linewidth(.2),Arrow3(3));
    
    shipout("My3DPicture");
    erase();
    
     

Log in to post a comment.