rgithub-actionsdevtoolscranremotes

Installing package dependencies only from binary (not source) using remotes::install_deps or devtools::install_deps


I'm running a Github actions workflow that installs dependencies using remotes::install_deps. However, one of the dependencies was recently updated (curl 5.0.1 -> 5.0.2), and the workflow now fails.

The root cause of this is that there is not a binary available yet for curl 5.0.2 on CRAN. Instead, install_deps tries to install curl 5.0.2 from source, which fails because libcurl isn't installed on the Github actions machine.

More broadly, though, my workflow doesn't depend on having the latest version of any of the dependencies, so I'd like to just install from binary for everything. That way i can avoid this issue cropping up every time a dependency is updated but the binary isn't available yet. How can I force install_deps to only install the latest binary available for every dependency?

Alternatively, how can I install a list of dependencies that uses only the latest binary available?

This idea has been mentioned in several places around the web, but I have yet to find a solution that enforces binary-only for install_deps:

For instance, adding the line: options(install.packages.compile.from.source = "never") for the install_deps call doesn't fix the issue. Neither does options("pkgType" = "binary")

The Github actions workflow is pretty standard:

jobs:
  generate-data:
    runs-on: ${{ matrix.config.os }}

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

    strategy:
      fail-fast: false
      matrix:
        config:
          - {os: ubuntu-latest,   r: 'release'}

    env:
      R_REMOTES_NO_ERRORS_FROM_WARNINGS: true
      RSPM: ${{ matrix.config.rspm }}
      GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}

    steps:
      - uses: actions/checkout@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-pandoc@v2

      - name: Query dependencies
        run: |
          install.packages('remotes')
          install.packages('sessioninfo')
          saveRDS(remotes::dev_package_deps(dependencies = TRUE), ".github/depends.Rds", version = 2)
          writeLines(sprintf("R-%i.%i", getRversion()$major, getRversion()$minor), ".github/R-version")
        shell: Rscript {0}

      - name: Cache R packages
        uses: actions/cache@v1
        with:
          path: ${{ env.R_LIBS_USER }}
          key: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-${{ hashFiles('.github/depends.Rds') }}
          restore-keys: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-

      - name: Install dependencies
        run: |
          remotes::install_deps(dependencies = TRUE)
        shell: Rscript {0}

Solution

  • Turns out the answer was to use a different Github Action to install the dependencies:

    jobs:
      generate-data:
        runs-on: ${{ matrix.config.os }}
    
        name: ${{ matrix.config.os }} (${{ matrix.config.r }})
    
        strategy:
          fail-fast: false
          matrix:
            config:
              - {os: ubuntu-latest,   r: 'release'}
    
        env:
          R_REMOTES_NO_ERRORS_FROM_WARNINGS: true
          RSPM: ${{ matrix.config.rspm }}
          GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
    
        steps:
          - uses: actions/checkout@v3
    
          - 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