Broken ghostscript configuration

7,105

Here's what worked for me:

sudo rmdir /usr/share/ghostscript/9.25/iccprofiles
sudo apt-get install --reinstall libgs9-common

Something had left an empty directory at /usr/share/ghostscript/9.25/iccprofiles. It appears that libgs9-common creates a symlink from /usr/share/ghostscript/9.25/iccprofiles to /usr/share/color/icc/ghostscript, but silently fails to create it if there's already something in the filesystem.

Share:
7,105

Related videos on Youtube

James
Author by

James

Updated on September 18, 2022

Comments

  • James
    James over 1 year

    Something has gone awry with my ghostscript configuration, whereby I get the following errors when, for example, using epstopdf


     ./base/gsicc_manage.c:1088: gsicc_open_search(): Could not find default_gray.icc 
    | ./base/gsicc_manage.c:1914: gsicc_init_iccmanager(): cannot find default icc profile
      ./base/gsicc_manage.c:1088: gsicc_open_search(): Could not find default_rgb.icc 
    | ./base/gsicc_manage.c:1708: gsicc_set_device_profile(): cannot find device profile
    
    **** Unable to open the initial device, quitting.
      ./base/gsicc_manage.c:1088: gsicc_open_search(): Could not find default_gray.icc 
    | ./base/gsicc_manage.c:1708: gsicc_set_device_profile(): cannot find device profile
    Unrecoverable error: unknownerror in .special_op
      ./base/gsicc_manage.c:1088: gsicc_open_search(): Could not find default_gray.icc 
    + ./base/gsicc_manage.c:2650: gs_setdefaultgrayicc(): cannot find default gray icc profile
    

    I figured out the following workaround (inserted in my .bashrc)

    alias gs='gs -sICCProfilesDir=/usr/share/color/icc/ghostscript/'<br>
    alias epstopdf='epstopdf --gsopt=-sICCProfilesDir=/usr/share/color/icc/ghostscript/' <br>
    alias ps2pdf='ps2pdf -sICCProfilesDir=/usr/share/color/icc/ghostscript/'
    

    However, I couldn't find a way of making this setting 'global'. E.g. when say epstopdf is called from export_fig matlab it gives similar errors to above, unless I implement a similar workaround.

    I think this has had knock-on effects of stopping printing from working properly on my system.

    Ubuntu 16.04  
    ghostscript, Version: 9.18~dfsg~0-0ubuntu2.6
    

    Any assistance greatly appreciated.

    • steeldriver
      steeldriver almost 7 years
      Complete SWAG - but have you tried re-installing the libgs9-common package?
    • James
      James almost 7 years
      I did this with sudo dpkg --purge --force-depends libgs9-common ... sudo apt-get install libgs9-common. Hmm it apears to have fixed epstopdf but stopped the workaround functioning for gs. Should I go ahead and purge libgs9-common fully (uninstalling dependencies) then reinstall all the packages?
    • steeldriver
      steeldriver almost 7 years
      I don't know . . . I would have tried sudo apt install --reinstall libgs9-common rather than the lower-level dpkg, but I don't know if the outcome would be different. Do you know where the /usr/share/color/icc/ghostscript/ files come from? I can't find a package that provides them (the default color profiles appear to live in /usr/share/ghostscript/9.18/iccprofiles/)
    • James
      James almost 7 years
      Reinstalling via apt was the same. The workaround needed updating to /usr/share/ghostscript/9.18/iccprofiles/ as you say. Any other culprit things to try reinstalling?
    • steeldriver
      steeldriver almost 7 years
      Please run gs --help and copy the list of Search paths into your question. Are any relevant environment variables defined (env | grep GS_)?
    • James
      James almost 7 years
      By default no icc-file-containing location shows up in the search path list for gs --help. By adding export GS_LIB=/usr/share/ghostscript/9.18/iccprofiles/ to .bashrc it does appear with gs --help, as expected. However, bizarrely the error persists exactly as before.
    • James
      James almost 7 years
    • Tobias
      Tobias over 5 years
      I have exactly the same problem. Did you find a way to fix it?
  • randomuser15995183
    randomuser15995183 over 5 years
    Worked for me too, in 18.04.
  • Andrea Lazzarotto
    Andrea Lazzarotto over 5 years
    Amazing. I had printing completely broken on Ubuntu 18.04 and then on 18.10, then I realized Evince couldn't open PS files. Your solution works perfectly.
  • cvhberger
    cvhberger over 5 years
    Ville, worked for me too! Thank you very much indeed! Was having problems with cups-pdf not printing into ~/PDF; turned out gs was failing with code 255 (thanks Volker for pointing that out) and to you for your recipe as it finally brought gs back from a broken state.