I am having a problem installing packages from Github when using Github Actions, and the resulting failure of R CMD check on Github, even for a package which works fine locally. I built a simple package which reproduces the problem. Overview:
- In the DESCRIPTION we have:
My actual problem is with one of my own Github packages, but I wanted to use a high quality Github package for the example.
tests/testthat/test-ex.Rfile looks like:
library(readr) expect_equal(my_function("2"), "2")
my_function() just returns the input. The whole packages passes R CMD check locally with no NOTES/WARNINGS/ERRORS.
- The package was created with all the (wonderful!) usethis tools, including
usethis::use_github_actions(). But when the R CMD check runs, via Github Actions, on Github, we see this error:
* checking for unstated dependencies in ‘tests’ ... WARNING Warning: 'library' or 'require' call not declared from: ‘readr’ * checking tests ... Running ‘testthat.R’ ERROR Running the tests in ‘tests/testthat.R’ failed. Last 13 lines of output: > > test_check("testing") [ FAIL 1 | WARN 0 | SKIP 0 | PASS 0 ] ══ Failed tests ════════════════════════════════════════════════════════════════ ── Error ('test-ex.R:1'): (code run outside of `test_that()`) ────────────────── <packageNotFoundError/error/condition> Error in `library(readr)`: there is no package called 'readr' Backtrace: ▆ 1. └─base::library(readr) at test-ex.R:1:0 [ FAIL 1 | WARN 0 | SKIP 0 | PASS 0 ] Error: Test failures Execution halted
It is as if
tidyverse/readr is never installed, despite its placement in the DESCRIPTION file. This is consistent with what I see in the log file:
Install/update packages ℹ Installing lockfile '.github/pkg.lock' → Will install 38 packages. → Will download 37 CRAN packages (10.03 MB). → Will download 1 package with unknown size.
I think that the "1 package with unknow size" refers to
tidyverse/readr but I don't see any evidence that it is is ever downloaded or installed.
Any ideas much appreciated!