Ubuntu – Broken ghostscript configuration

16.04ghostscript

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.

Best Answer

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.