Ghostscript not finding GS_LIB


I am trying to use gs command (ghostscript) inside a python script, but it seems that gs is not able to find the GS_LIB path (that is usually /usr/share/ghostscript/…)

GPL Ghostscript 9.26: Can't find initialization file

I am sure this folders/files are present on the snap, and trying to set this variable on both snapcraft.yaml and hardcoding it on subprocess env option does not work.

Anything I am missing?
Thanks for your attention.

I am having the same problem with ghostscript 9.5 did you find a solution?

I have added:

    GS_LIB: $SNAP/usr/share/ghostscript/9.26/Resource/Init 
    GS_FONTPATH: $SNAP/usr/share/ghostscript/9.26/Resource/Font

to my core18 snapcraft.yaml (adjust to your GS version as needed)

In my case the solution was:

GS_LIB: $SNAP/usr/share/ghostscript/9.50/Resource/Init
GS_FONTPATH: $SNAP/usr/share/ghostscript/9.50/Resource/Font

emphasizing the 9.50 instead of just 9.5 which I did previousy.

I thought it would be nice to have a solution that works without having to care about GS’ version numbers in the future. For my core20 snaps I have added this to my snapcraft.yaml:

    GS_LIB: $SNAP/usr/share/ghostscript/Init 
    GS_FONTPATH: $SNAP/usr/share/ghostscript/Font
    GS_OPTIONS: -sGenericResourceDir=$SNAP/usr/share/ghostscript/ -sICCProfilesDir=$SNAP/usr/share/color/icc/ghostscript/

    plugin: nil
      - ghostscript
      - icc-profiles-free 
      - ghostscript
    override-prime: |
      snapcraftctl prime
      gslibpath=$(gs -h | grep  Resource/Init | tr -d ' ':)
      ln -s -f ${gslibpath/\/usr\/share\/ghostscript/.} .${gslibpath}/../../../Init
      gsfontpath=$(gs -h | grep  Resource/Font | tr -d ' ':)
      ln -s -f ${gsfontpath/\/usr\/share\/ghostscript/.} .${gsfontpath}/../../../Font