covr::package_coverage reports "No such file or directory"
Asked Answered
G

1

7

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.

Gemology answered 4/7, 2019 at 22:3 Comment(1)
did you find a solution or cause of the issue? I'm facing the same issue and I'm trying to solve it.Flightless
H
4

I encountered this problem too with a under-development package that is not installed. The error message has the path like this:

... /pkgname/R/pkgname': No such file or directory

where pkgname is 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 called devtools::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 called covr::package_coverage(), and then called covr::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 by devtools::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 of covr::package_coverage(), without the need to loading the package.

I used covr 3.5.1, R 4.2.0 in Windows.

Hylan answered 17/5, 2022 at 12:9 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.