r-lib/actions/setup-r-dependencies@v2 does not install Github packages

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:

  1. In the DESCRIPTION we have:
Remotes: 
    tidyverse/readr   

My actual problem is with one of my own Github packages, but I wanted to use a high quality Github package for the example.

  1. My tests/testthat/test-ex.R file 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.

  1. 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!

You need to declare readr as a dependency, i.e. you need to add

Imports: readr

or

Suggests: readr

to DESCRIPTION.

1 Like

Thanks @Gabor! That did the trick.

This topic was automatically closed 7 days after the last reply. 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.