Windows unable to find ghostscript in `r-lib/actions/check-r-package`

I am using the github action r-lib/actions/check-r-package for checking my package aravind-j / germinationmetrics. My package includes a pdf vignette and hence requires ghostscript for checking the package.

I am the following error with ubuntu and windows.

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

I have successfully installed it using the following code in yml.

      - name: Install Ghostscript on Linux
        if: runner.os == 'Linux'
        run: sudo DEBIAN_FRONTEND=noninteractive apt-get install --yes ghostscript

      - name: Install Ghostscript on Windows
        if: runner.os == 'Windows'
        run: choco install ghostscript --no-progress

However, the error persists for windows despite ghostscript being installed.

How to force the Windows build to discover ghostscript ?

I don't know how R finds ghostscript unfortunately. Assuming the installation from chocolatey works, this is more of a generic R question.

From the source code it seems that you can set some environment variables to help R finding it: r-source/admin.R at d19d3c44a10014801e00e375eeb5b75e00b590ce · wch/r-source · GitHub

The solution is to set the environment variable R_GSCMD. But the rcmdcheck function in r-lib/actions/check-r-package@v2 does not use envargument.

But a direct R script works.

on:
  push:
    branches: [main, master]
  pull_request:
    branches: [main, master]

name: R-CMD-check

jobs:
  R-CMD-check:
    runs-on: ${{ matrix.config.os }}

    name: ${{ matrix.config.os }} (${{ matrix.config.r }})

    strategy:
      fail-fast: false
      matrix:
        config:
          - {os: macOS-latest,   r: 'release'}
          - {os: windows-latest, r: 'release'}
          - {os: ubuntu-latest,   r: 'devel', http-user-agent: 'release'}
          - {os: ubuntu-latest,   r: 'release'}
          - {os: ubuntu-latest,   r: 'oldrel-1'}

    env:
      GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
      R_KEEP_PKG_SOURCE: yes

    steps:
      - uses: actions/checkout@v2

      - uses: r-lib/actions/setup-pandoc@v2

      - uses: r-lib/actions/setup-tinytex@v2
      - uses: r-lib/actions/setup-r@v2
        with:
          r-version: ${{ matrix.config.r }}
          http-user-agent: ${{ matrix.config.http-user-agent }}
          use-public-rspm: true

      - uses: r-lib/actions/setup-r-dependencies@v2
        with:
          extra-packages: any::rcmdcheck
          needs: check

      - name: Check
        run: |
          options(crayon.enabled = TRUE)
          Sys.setenv(R_GSCMD = "C:\Program Files\gs\gs9.56.1\bin\gswin64.exe")
          rcmdcheck::rcmdcheck(args = c("--as-cran", "--run-donttest"),
                               build_args = c("--compact-vignettes=gs+qpdf"),
                               error_on = "warning", check_dir = "check")
        shell: Rscript {0}

This topic was automatically closed after 45 days. New replies are no longer allowed.


If you have a query related to it or one of the replies, start a new topic and refer back with a link.