r-lib / covr

Test coverage reports for R
https://covr.r-lib.org
Other
336 stars 117 forks source link

covr not working with renv #571

Open JT-39 opened 5 months ago

JT-39 commented 5 months ago

When running covr::package_coverage() in the project where I have my package, the function runs fine and produces the output one would expect (code coverage scores for all the functions).

However, after initialising {renv} and creating a renv.lock file and renv/ folder, the covr package fails. This is the code and output I get:

> covr::package_coverage()
Error: Failure in `C:/Users/jtufts/AppData/Local/Temp/RtmpKqr5sO/R_LIBS176043926f2c/dfeR/dfeR-tests/testthat.Rout.fail`
ELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> library(testthat)
> library(dfeR)
Error in loadNamespace(x) : there is no package called 'covr'
> 
> test_check("dfeR")
Error in loadNamespace(x) : there is no package called 'desc'
Calls: test_check ... loadNamespace -> withRestarts -> withOneRestart -> doWithOneRestart
Execution halted
Error in loadNamespace(x) : there is no package called 'covr'
Calls: <Anonymous> ... loadNamespace -> withRestarts -> withOneRestart -> doWithOneRestart

This is also fails in the GitHub Actions I have setup which runs covr::codecov, with the same errors.

Is this a bug?

P.S. I have tried adding covr and desc to the renv.lock file (& to Imports in DESCRIPTION) but the same error occurs

radbasa commented 5 months ago

Because you initialized renv, you may have to reinstall all your package dependecies under renv. That includes covr.

Note: packages don't really work well with renv.