r-lib / covr

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

Error in file(con, "r") : cannot open the connection #213

Closed msusplugas closed 8 years ago

msusplugas commented 8 years ago

I tried to use covr with the following example: http://stackoverflow.com/a/29359404/4829233 but I got the following errors:

> test("testcovr")
Loading testcovr
Testing testcovr
doublefun: .

DONE =====================================================================================================================================================
> ## Testing testcovr
> ## doublefun : .
> 
> library(covr)
> package_coverage("testcovr")
Error in file(con, "r") : cannot open the connection
In addition: Warning messages:
1: running command '"C:/R/R-32~1.3/bin/x64/R" CMD INSTALL --example --install-tests --with-keep.source --no-multiarch -l "C:\Users\MICHSUSP\AppData\Local\Temp\Rtmp6zf5jM\R_LIBS2b645d962d4e" "//VFBDN501/Home82$/MICHSUSP/MY Documents/RPackage/testcovr"' had status 1 
2: In utils::install.packages(repos = NULL, lib = tmp_lib, pkg$path,  :
  installation of package ‘//VFBDN501/Home82$/MICHSUSP/MY Documents/RPackage/testcovr’ had non-zero exit status
3: In file(con, "r") :
  cannot open file 'C:/Users/MICHSUSP/AppData/Local/Temp/Rtmp6zf5jM/R_LIBS2b645d962d4e/testcovr/R/testcovr': No such file or directory
> 

I got similar Errors with my other R packages

maodunzhe commented 8 years ago

It seems that the process of installation of the package into the temporary directory failed, since you did not provide any other information , I would recommend you try to update certain related r packages like devtools, testthat, covr and also double check the correctness of the source/test code during the process. I had this issue before which turns out to be an out-of-date testthat package that causes the problem. Hope it helps.

msusplugas commented 8 years ago

Thank you, but it doesn't seem to work. The update of the R packages devtools/testthat and covr did not work, I have already the latest R Packages with R 3.2.3:

> version
               _                           
platform       x86_64-w64-mingw32          
arch           x86_64                      
os             mingw32                     
system         x86_64, mingw32             
status                                     
major          3                           
minor          2.3                         
year           2015                        
month          12                          
day            10                          
svn rev        69752                       
language       R                           
version.string R version 3.2.3 (2015-12-10)
nickname       Wooden Christmas-Tree   
> packageVersion("testthat")
[1] ‘1.0.2’
> packageVersion("covr")
[1] ‘2.1.0’
> packageVersion("devtools")
[1] ‘1.12.0’

Regarding the full logs of the creation of this test Folder:

Restarting R session...

> library(devtools)
Warning message:
package ‘devtools’ was built under R version 3.2.5 
> library(covr)
Warning message:
package ‘covr’ was built under R version 3.2.5 
> create("testcovr")
Creating package 'testcovr' in '\\VFBDN501/Home82$/MICHSUSP/MY Documents/RPackage/XYZ'
No DESCRIPTION found. Creating with values:

Package: testcovr
Title: What the Package Does (one line, title case)
Version: 0.0.0.9000
Authors@R: person("First", "Last", email = "first.last@example.com", role = c("aut", "cre"))
Description: What the package does (one paragraph).
Depends: R (>= 3.2.3)
License: What license is it under?
Encoding: UTF-8
LazyData: true
* Creating `testcovr.Rproj` from template.
* Adding `.Rproj.user`, `.Rhistory`, `.RData` to ./.gitignore
> use_testthat("testcovr")
* Adding testthat to Suggests
* Creating `tests/testthat`.
* Creating `tests/testthat.R` from template.
##
### Add the two R files as asked in stackoverflow
##
> test("testcovr")
Loading testcovr
Loading required package: testthat
Testing testcovr
doublefun: .

DONE =====================================================================================================================================================
Warning message:
package ‘testthat’ was built under R version 3.2.5 
> library(covr)
> package_coverage("testcovr")
Error in file(con, "r") : cannot open the connection
In addition: Warning messages:
1: running command '"C:/R/R-32~1.3/bin/x64/R" CMD INSTALL --example --install-tests --with-keep.source --no-multiarch -l "C:\Users\MICHSUSP\AppData\Local\Temp\RtmpOMsoKL\R_LIBS1b5442e7407d" "//VFBDN501/Home82$/MICHSUSP/MY Documents/RPackage/XYZ/testcovr"' had status 1 
2: In utils::install.packages(repos = NULL, lib = tmp_lib, pkg$path,  :
  installation of package ‘//VFBDN501/Home82$/MICHSUSP/MY Documents/RPackage/XYZ/testcovr’ had non-zero exit status
3: In file(con, "r") :
  cannot open file 'C:/Users/MICHSUSP/AppData/Local/Temp/RtmpOMsoKL/R_LIBS1b5442e7407d/testcovr/R/testcovr': No such file or directory
> zero_coverage(package_coverage("testcovr"))
Error in file(con, "r") : cannot open the connection
In addition: Warning messages:
1: running command '"C:/R/R-32~1.3/bin/x64/R" CMD INSTALL --example --install-tests --with-keep.source --no-multiarch -l "C:\Users\MICHSUSP\AppData\Local\Temp\RtmpOMsoKL\R_LIBS1b543aee6f50" "//VFBDN501/Home82$/MICHSUSP/MY Documents/RPackage/XYZ/testcovr"' had status 1 
2: In utils::install.packages(repos = NULL, lib = tmp_lib, pkg$path,  :
  installation of package ‘//VFBDN501/Home82$/MICHSUSP/MY Documents/RPackage/XYZ/testcovr’ had non-zero exit status
3: In file(con, "r") :
  cannot open file 'C:/Users/MICHSUSP/AppData/Local/Temp/RtmpOMsoKL/R_LIBS1b543aee6f50/testcovr/R/testcovr': No such file or directory
> getwd()
[1] "\\\\VFBDN501/Home82$/MICHSUSP/MY Documents/RPackage/XYZ"
msusplugas commented 8 years ago

After reinstalling covr using source, everything works now.