Github Action failing with R CMD check, using stale commit?

I'm not sure how best to describe this, hence the rather vague title.

I have a package that uses Github Actions to run checks. You can see the workflow file here:

It's basically the same as the check-standard workflow in the r-lib/actions repo, with some tweaks for my particular requirements. My latest commit is failing the check for the MacOS build, with this error:

Run remotes::install_deps(dependencies = TRUE)
Error: Error: HTTP error 404.
  Not Found

  Did you spell the repo owner (`hongooi73`) and repo name (`AzureGraph`) correctly?
  - If spelling is correct, check that you have the required permissions to access the repo.
Execution halted
Error: Process completed with exit code 1.

The step in question is this. It just scans the DESCRIPTION file and installs the package's dependencies -- all very straightforward.

      - name: Install dependencies
        run: |
          remotes::install_deps(dependencies = TRUE)
          remotes::install_cran(c("pkgbuild", "rcmdcheck", "drat"))
        shell: Rscript {0}

It looks like it's trying to install a dependency from the hongooi73/AzureGraph repo, which no longer exists. But my DESCRIPTION doesn't list hongooi73/AzureGraph as a remote dependency; it uses Azure/AzureGraph of which hongooi73/AzureGraph was a fork. It used to refer to hongooi73/AzureGraph, but that was several commits ago. Indeed, the Linux and Windows checks both run without problems so they are clearly using the correct repo location.

What can be causing this failure? And how do I fix it? I've already tried rerunning the workflow, and deleting older workflows.

After some digging, it looks like this is because of a bad cache. The cache is setup by the following steps in the workflow:

- name: Query dependencies
  run: |
    install.packages('remotes')
    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
  if: runner.os != 'Windows'
  uses: actions/cache@v2
  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-

So the cache key is obtained from the OS, R version, and list of dependencies. However, the restore key doesn't use the dependencies, only the OS and R version. Hence it reads the old cache, which is now invalid because of the changed repo location.

The check ran successfully on Windows because the cache isn't used there, and on Linux because the earlier build failed and the cache wasn't created.

More questions though:

  • Why is the restore key different to the regular key? I looked at r-lib/actions and this is still the case in check-standard.yaml.
  • How can I easily fix this?

I fixed/worked around this by changing the cache key. Apparently there is still no way to clear the cache.

Yes, this is expected behavior, remotes was trying to update the installed package from the remote repository, but since it no longer existed the cache was invalid, so bumping the key as you did was the right solution.

The restore key controls the fallback behavior if a cache miss occurs, e.g. if the dependencies change it uses the last successful cache on the same OS and R version.

@jimhester thanks for the reply. Could you explain why the restore key is different, though? If the dependencies change, don't you WANT to reinstall them from scratch?

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.