[Rd] R CMD check: Sys.getenv("R_GSCMD") cannot contain full pathname (contrary to docs)

Henrik Bengtsson hb at biostat.ucsf.edu
Fri Apr 20 23:00:08 CEST 2012


in help("R_GSCMD") it says "R_GSCMD: Optional. The path to
Ghostscript, used by dev2bitmap, bitmap and embedFonts. Consulted when
those functions are invoked.".  However, if 'R_GSCMD' contains a full
pathname to the Ghostscript executable (as above "path" indicates),

> Sys.getenv("R_GSCMD")
[1] "C:\\Program Files\\gs\\gs8.71\\bin\\gswin32c.exe"

then 'R CMD check' will report

* checking sizes of PDF files under 'inst/doc' ... NOTE
Unable to find GhostScript executable to run checks on size reduction

Setting 'R_GSCMD' to "gswin32c.exe" and asserting that it is the PATH
(this is on Windows), it works.

In the local function check_doc_size() of tools:::.check_packages()
[cf. http://svn.r-project.org/R/trunk/src/library/tools/R/check.R],
the Ghostscript executable is retrieved as:

 gs_cmd <- find_gs_cmd(Sys.getenv("R_GSCMD", ""))

and if nzchar(gs_cmd) is FALSE, then the 'R CMD check' NOTE appears.
Inspecting tools:::find_gs_cmd, this corresponds to

 gs_cmd <- Sys.which(Sys.getenv("R_GSCMD", ""))

iff 'R_GSCMD' is set.  In other words, tools:::find_gs_cmd() assumes a
basename not a full pathname.

Update tools:::find_gs_cmd() to test for file existence before turning
to Sys.which(), e.g.

find_gs_cmd <- function (gs_cmd)
    if (!nzchar(gs_cmd)) {
        if (.Platform$OS.type == "windows") {
            gs_cmd <- Sys.which("gswin64c")
            if (!nzchar(gs_cmd))
                gs_cmd <- Sys.which("gswin32c")
        else Sys.which("gs")
    } else {
      if (file.exists(gs_cmd) && !file.info(gs_cmd)$isdir)


> sessionInfo()
R version 2.15.0 Patched (2012-04-08 r58935)
Platform: x86_64-pc-mingw32/x64 (64-bit)

[1] LC_COLLATE=English_United States.1252
[2] LC_CTYPE=English_United States.1252
[3] LC_MONETARY=English_United States.1252
[5] LC_TIME=English_United States.1252

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base

loaded via a namespace (and not attached):
[1] R.methodsS3_1.4.0 tools_2.15.0

More information about the R-devel mailing list