Find a GhostScript Executable

Find a GhostScript executable in a cross-platform way.

find_gs_cmd(gs_cmd = "")

The name, full or partial path of a GhostScript executable.


The details differ by platform.

On a Unix-alike, the GhostScript executable is usually called gs. The name (and possibly path) of the command is taken first from argument gs_cmd then from the environment variable R_GSCMD and default gs. This is then looked for on the system path and the value returned if a match is found.

On Windows, the name of the command is taken from argument gs_cmd then from the environment variables R_GSCMD and GSC. If neither of those produces a suitable command name, gswin64c and gswin32c are tried in turn. In all cases the command is looked for on the system PATH.

Note that on Windows (and some other OSes) there are separate GhostScript executables to display Postscript/PDF files and to manipulate them: this function looks for the latter.


A character string giving the full path to a GhostScript executable if one was found, otherwise an empty string.

  • find_gs_cmd
  • GSC
library(tools) # NOT RUN { ## Suppose a Solaris system has GhostScript 9.00 on the path and ## 9.07 in /opt/csw/bin. Then one might set Sys.setenv(R_GSCMD = "/opt/csw/bin/gs") # }
Documentation reproduced from package tools, version 3.6.0, License: Part of R 3.6.0

Community examples

Looks like there are no examples yet.