I'm trying to see the code coverage of sumbose/iRF, so I did a git clone, started an R session inside of the directory, and
> library(covr)
> package_coverage()
Error in file(con, "r") : cannot open the connection
In addition: Warning messages:
1: In utils::install.packages(repos = NULL, lib = tmp_lib, pkg$path, :
installation of package ‘/private/tmp/iRF’ had non-zero exit status
2: In file(con, "r") :
cannot open file '/private/var/folders/ny/f06ns0d568bgf6s559z8j_9m0000gn/T/RtmpAr8dLV/R_LIBS168866d1ef32f/iRF/R/iRF': No such file or directory
However, both R CMD INSTALL iRF and install.packages('iRF', repos = NULL) installs the package as expected.
I encountered this problem too with a under-development package that is not installed. The error message has the path like this:
where
pkgnameis the package name.I used VS Code and called
covr::package_coverage(), with the package folder as the working directory. I could consistently reproduce the error, and then I noticed that this error occurred if I calleddevtools::load_all()first.I found that, for unknown reasons, this error disappeared if I started an R session and did not run
devtools::load_all(). I did not need to (and maybe should not) load the package.covr::package_coverage()ran normally in that session without loading the package.If I called
devtools::load_all()after I calledcovr::package_coverage(), and then calledcovr::package_coverage()again, it would fail in the same session.So I think the solution is simple, though a little bit counter intuitive:
Call
covr::package_coverage()in a session that does not have the package loaded bydevtools::load_all().I could call
covr::package_coverage()several times in this session without problems. Changes I made to files were reflected correctly in the output ofcovr::package_coverage(), without the need to loading the package.I used covr 3.5.1, R 4.2.0 in Windows.