0

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}
  • `r2u` does this by setting a `bspm` option to prefer binary over source so that _is_ a working solution. Note that `r2u` by its very design is Ubuntu Linux only. If that is not a concern (i.e. it isn;t for me: I don't most of my CI on Linux only) then the r2u site may be of interest: https://eddelbuettel.github.io/r2u. – Dirk Eddelbuettel Aug 15 '23 at 15:53

1 Answers1

0

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
  • Nice find! (Now, as this is by choice on 'Ubuntu latest' and 'release', I was curious how this solution (using `pak`, a cache, ...) would fare relative to the (to me, simpler) r2u setup so I quickly cloned your repo into a private one and set up a horserace (in both cases up to running your script, but not committing or showing sys,info). For two initial runs, r2u is faster at clearly under one minute where the setup-r-dependency action takes over two. May get better once the cache is filled and use though. – Dirk Eddelbuettel Aug 15 '23 at 21:18
  • (And the reason I got curious is that the "`curl` fails to build" hit a related prod CI job today so I had a reason to look around and your question hit the same topic.) – Dirk Eddelbuettel Aug 15 '23 at 21:19