[英]covr::package_coverage reports "No such file or directory"
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我正在尝试查看sumbose/iRF的代码覆盖率,所以我做了一个
git clone
,在目录中启动了一个 R 会话,然后
> 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.但是,
R CMD INSTALL iRF
和install.packages('iRF', repos = NULL)
按预期安装包。
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.其中
pkgname
是包名称。
I used VS Code and called covr::package_coverage()
, with the package folder as the working directory.我使用 VS Code 并调用
covr::package_coverage()
,将包文件夹作为工作目录。 I could consistently reproduce the error, and then I noticed that this error occurred if I called devtools::load_all()
first.我可以始终如一地重现该错误,然后我注意到如果我先调用
devtools::load_all()
就会发生此错误。
I found that, for unknown reasons, this error disappeared if I started an R session and did not run devtools::load_all()
.我发现,由于未知原因,如果我启动了一个 R 会话并且没有运行
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. covr::package_coverage()
在该会话中正常运行而无需加载包。
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.如果我在调用
covr::package_coverage()
devtools::load_all()
) ,然后再次调用covr::package_coverage()
,它将在同一个会话中失败。
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()
.在没有
devtools::load_all()
加载包的会话中调用covr::package_coverage()
) 。
I could call covr::package_coverage()
several times in this session without problems.我可以在这个会话中多次调用
covr::package_coverage()
没有问题。 Changes I made to files were reflected correctly in the output of covr::package_coverage()
, without the need to loading the package.我对文件所做的更改正确反映在
covr::package_coverage()
的输出中,无需加载包。
I used covr 3.5.1, R 4.2.0 in Windows.我在 Windows 中使用了 covr 3.5.1、R 4.2.0。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.