Skip to content

Instantly share code, notes, and snippets.

@matflores
Created September 10, 2012 17:53
Show Gist options
  • Save matflores/3692524 to your computer and use it in GitHub Desktop.
Save matflores/3692524 to your computer and use it in GitHub Desktop.
Fixing conflicts between Ghostscript & gs

Fixing conflicts between Ghostscript & gs

If you are using gs for managing your gem sets and you are also using any tool that relies on Ghostscript for converting PDF files to other formats (e.g. GraphicsMagick, docsplit, etc.), you may find that one of the two will fail due to a conflict between the two gs commands.

There are two possible solutions to this problem:

  • rename the gs command to something else (e.g. gset, gs_, etc), and leave Ghostscript's gs as the only gs command in your system.
  • edit GraphicMagick's delegates file and specify the full path to the gs command. This file is located in the lib/GraphicsMagick/config directory of your GraphicsMagick's installation. If GraphicsMagick was installed via homebrew, you can find the full path to this file by running brew list graphicsmagick | grep delegates. Each transformation supported by gm convert will have a matching configuration line in this file. All delegations which have a command starting with command='"gm" must be updated using the full path to the Ghostscript's executable file (e.g. command='"/usr/local/bin/gs").

I have not tested it yet, but ImageMagick uses the same delegates.mgk file so the same solution may apply.

If due to the PATH order gs executes Ghostscript, this trick would make gs to always execute gs instead:

alias gs="`brew list ruby | grep bin/gs`"
@JamoCA
Copy link

JamoCA commented Nov 12, 2015

Thanks for this tip! I edited our GraphicsMagick "delegates.mgk" file and replaced @PSDelegate@ with the physical path to GhostScript. As a result, PDF-to-Image conversion is functioning properly and the path isn't required to be entered in the system path.

@danielhdz56
Copy link

Thank you i can also confirm this works!

@inakiarroyo
Copy link

In my case gs was shadowed by Prezto git module: https://github.com/sorin-ionescu/prezto/tree/master/modules/git#shadows. It may be helpful for someone looking around this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment