I am trying to locate an external file with .yml
extension for creating unit test with testthat
while building a R package, the file is placed under \inst
folder, as mentioned here https://r-pkgs.org/data.html#data-extdata. Am using system.file()
to load the file with yaml
package for some unit test (not base::system.file()
, so that pkgload:::shim_system.file()
can intercept). The tests passes if I do devtools::test()
, but it keeps throwing error when I run devtools::check()
.
However, interestingly after lots of trials I found out that devtools::check()
does not throw any error if I save the file with .txt
extension instead of .yaml
/.yml
.
## inside test_that()
## cf <- system.file("config", "config1.yml", package = "mypackage", mustWork = TRUE)
## Error note after devtools::check()
Error in `system.file("config", "config1.yml", package = "mypackage", mustWork = TRUE)`: no file found
Backtrace:
x
1. \-base::system.file(...) test-set_config.R:34:2
[ FAIL 1 | WARN 0 | SKIP 0 | PASS 15 ]
# -------------------------------------------------------------
## No error in devtools::check() when config1.yml is renamed as config1.txt !!
Anyone experienced the same? Am using latest version of devtools
as on CRAN (v2.4.2), on R 4.1.1. If yes, is there any way to keep using .yaml
/.yml
, and not .txt
?
UPDATE
I did accidentally keep [.]yml
, [.]yaml
in .Rbuildignore
to ignore the continuous integration yaml files, have made them specifc instead of wildcards - and it is working now! Apologies for raising a false alarm, I was myself quite confused when I got this weird thing. https://github.com/r-lib/devtools/issues/2384#issuecomment-947943050
Figured out the problem, finally, the culprit was my .Rbuildignore
- I accidentally kept [.]yml
, [.]yaml
in .Rbuildignore
to ignore the continuous integration yaml files while building the package. I modified them and made them specific, instead of wildcards - and it is working now! Apologies for raising a false alarm; I was quite confused when I got this weird thing. Thanks, @jimhester, who responded on github devtools
issues