extendr / rextendr

An R package that helps scaffolding extendr-enabled packages or compiling Rust code dynamically
https://extendr.github.io/rextendr/
Other
181 stars 27 forks source link

`R CMD check` fails with default configuration #257

Closed Ilia-Kosenkov closed 1 year ago

Ilia-Kosenkov commented 1 year ago

R CMD check fails with the default configuration when a temporary directory is used for testing.

Can be observed when executing devtools::check() or rcmdcheck::rcmdcheck() (with check_dir left unset or painting to a place outside of the package folder).

Error in `private$handle_error()`:
! testthat subprocess failed to start, stderr:
Error: No root directory found in C:/Users/<redacted>/AppData/Local/Temp/RtmpcR3mjO/file9f872c131b3/rextendr.Rcheck/tests/testthat or its parent directories. Root criterion: contains a file "DESCRIPTION"

In addition: Warning message:

package 'testthat' was built under R version 4.2.3 

Caused by error:
! R session crashed with exit code 1
Backtrace:
     ▆
  1. └─testthat::test_check("rextendr")
  2.   └─testthat::test_dir(...)
  3.     └─testthat:::test_files(...)
  4.       └─testthat:::test_files_parallel(...)
  5.         ├─testthat::with_reporter(...)
  6.         │ └─base::tryCatch(...)
  7.         │   └─base (local) tryCatchList(expr, classes, parentenv, handlers)
  8.         │     └─base (local) tryCatchOne(expr, names, parentenv, handlers[[1L]])
  9.         │       └─base (local) doTryCatch(return(expr), name, parentenv, handler)
 10.         └─testthat:::parallel_event_loop_chunky(queue, reporters)
 11.           └─queue$poll(Inf)
 12.             └─base::lapply(...)
 13.               └─testthat (local) FUN(X[[i]], ...)
 14.                 └─private$handle_error(msg, i)
 15.                   └─rlang::abort(...)
Execution halted
devtools::check() ``` ══ Documenting ═════════════════════════════════════════════════════════════════ ℹ Updating rextendr documentation ℹ Loading rextendr ══ Building ════════════════════════════════════════════════════════════════════ Setting env vars: • CFLAGS : -Wall -pedantic • CXXFLAGS : -Wall -pedantic • CXX11FLAGS: -Wall -pedantic • CXX14FLAGS: -Wall -pedantic • CXX17FLAGS: -Wall -pedantic • CXX20FLAGS: -Wall -pedantic ── R CMD build ───────────────────────────────────────────────────────────────── * checking for file 'E:\OneDrive\Development\OSS\rextendr/DESCRIPTION' ... OK * preparing 'rextendr': * checking DESCRIPTION meta-information ... OK * installing the package to build vignettes * creating vignettes ... OK * checking for LF line-endings in source and make files and shell scripts * checking for empty or unneeded directories * building 'rextendr_0.2.0.9000.tar.gz' ══ Checking ════════════════════════════════════════════════════════════════════ Setting env vars: • _R_CHECK_CRAN_INCOMING_REMOTE_ : FALSE • _R_CHECK_CRAN_INCOMING_ : FALSE • _R_CHECK_FORCE_SUGGESTS_ : FALSE • _R_CHECK_PACKAGES_USED_IGNORE_UNUSED_IMPORTS_: FALSE • NOT_CRAN : true ── R CMD check ───────────────────────────────────────────────────────────────── * using log directory 'C:/Users//AppData/Local/Temp/RtmpcR3mjO/file9f872c131b3/rextendr.Rcheck' * using R version 4.2.2 (2022-10-31 ucrt) * using platform: x86_64-w64-mingw32 (64-bit) * using session charset: UTF-8 * using options '--no-manual --as-cran' * checking for file 'rextendr/DESCRIPTION' ... OK * this is package 'rextendr' version '0.2.0.9000' * package encoding: UTF-8 * checking package namespace information ... OK * checking package dependencies ... OK * checking if this is a source package ... NOTE Found the following apparent object files/libraries: inst/libgcc_mock/gcc_mock.o inst/libgcc_mock/libgcc_eh.a inst/libgcc_mock/libgcc_s.a Object files/libraries should not be included in a source package. * checking if there is a namespace ... OK * checking for executable files ... OK * checking for hidden files and directories ... NOTE Found the following hidden files and directories: .idea .vscode These were most likely included in error. See section 'Package structure' in the 'Writing R Extensions' manual. * checking for portable file names ... OK * checking whether package 'rextendr' can be installed ... OK * checking installed package size ... OK * checking package directory ... OK * checking for future file timestamps ... NOTE unable to verify current time * checking 'build' directory ... OK * checking DESCRIPTION meta-information ... OK * checking top-level files ... OK * checking for left-over files ... OK * checking index information ... OK * checking package subdirectories ... OK * checking R files for non-ASCII characters ... OK * checking R files for syntax errors ... OK * checking whether the package can be loaded ... OK * checking whether the package can be loaded with stated dependencies ... OK * checking whether the package can be unloaded cleanly ... OK * checking whether the namespace can be loaded with stated dependencies ... OK * checking whether the namespace can be unloaded cleanly ... OK * checking loading without being on the library search path ... OK * checking dependencies in R code ... OK * checking S3 generic/method consistency ... OK * checking replacement functions ... OK * checking foreign function calls ... OK * checking R code for possible problems ... OK * checking Rd files ... OK * checking Rd metadata ... OK * checking Rd line widths ... OK * checking Rd cross-references ... OK * checking for missing documentation entries ... OK * checking for code/documentation mismatches ... OK * checking Rd \usage sections ... OK * checking Rd contents ... OK * checking for unstated dependencies in examples ... OK * checking installed files from 'inst/doc' ... OK * checking files in 'vignettes' ... OK * checking examples ... OK * checking for unstated dependencies in 'tests' ... OK * checking tests ... Running 'testthat.R' ERROR Running the tests in 'tests/testthat.R' failed. Last 13 lines of output: 2. └─testthat::test_dir(...) 3. └─testthat:::test_files(...) 4. └─testthat:::test_files_parallel(...) 5. ├─testthat::with_reporter(...) 6. │ └─base::tryCatch(...) 7. │ └─base (local) tryCatchList(expr, classes, parentenv, handlers) 8. │ └─base (local) tryCatchOne(expr, names, parentenv, handlers[[1L]]) 9. │ └─base (local) doTryCatch(return(expr), name, parentenv, handler) 10. └─testthat:::parallel_event_loop_chunky(queue, reporters) 11. └─queue$poll(Inf) 12. └─base::lapply(...) 13. └─testthat (local) FUN(X[[i]], ...) 14. └─private$handle_error(msg, i) 15. └─rlang::abort(...) Execution halted * checking for unstated dependencies in vignettes ... OK * checking package vignettes in 'inst/doc' ... OK * checking re-building of vignette outputs ... OK * checking for non-standard things in the check directory ... OK * checking for detritus in the temp directory ... OK * DONE Status: 1 ERROR, 3 NOTEs See 'C:/Users//AppData/Local/Temp/RtmpcR3mjO/file9f872c131b3/rextendr.Rcheck/00check.log' for details. ── R CMD check results ──────────────────────────────── rextendr 0.2.0.9000 ──── Duration: 26.3s ❯ checking tests ... See below... ❯ checking if this is a source package ... NOTE Found the following apparent object files/libraries: inst/libgcc_mock/gcc_mock.o inst/libgcc_mock/libgcc_eh.a inst/libgcc_mock/libgcc_s.a Object files/libraries should not be included in a source package. ❯ checking for hidden files and directories ... NOTE Found the following hidden files and directories: .idea .vscode These were most likely included in error. See section 'Package structure' in the 'Writing R Extensions' manual. ❯ checking for future file timestamps ... NOTE unable to verify current time ── Test failures ───────────────────────────────────────────────── testthat ──── > library(testthat) Warning message: package 'testthat' was built under R version 4.2.3 > library(rextendr) > > # no need to run tests if cargo isn't installed. > cargo_available <- system2("cargo") == 0L Rust's package manager Usage: cargo [+toolchain] [OPTIONS] [COMMAND] Options: -V, --version Print version info and exit --list List installed commands --explain Run `rustc --explain CODE` -v, --verbose... Use verbose output (-vv very verbose/build.rs output) -q, --quiet Do not print cargo log messages --color Coloring: auto, always, never -C Change to DIRECTORY before doing anything --frozen Require Cargo.lock and cache are up to date --locked Require Cargo.lock is up to date --offline Run without accessing the network --config Override a configuration value -Z Unstable (nightly-only) flags to Cargo, see 'cargo -Z help' for details -h, --help Print help Some common cargo commands are (see all commands with --list): build, b Compile the current package check, c Analyze the current package and report errors, but don't build object files clean Remove the target directory doc, d Build this package's and its dependencies' documentation new Create a new cargo package init Create a new cargo package in an existing directory add Add dependencies to a manifest file remove Remove dependencies from a manifest file run, r Run a binary or example of the local package test, t Run the tests bench Run the benchmarks update Update dependencies listed in Cargo.lock search Search registry for crates publish Package and upload this package to the registry install Install a Rust binary. Default location is $HOME/.cargo/bin uninstall Uninstall a Rust binary See 'cargo help ' for more information on a specific command. > not_cran <- identical(Sys.getenv("NOT_CRAN"), "true") > > if (cargo_available && not_cran) { + test_check("rextendr") + } Starting 8 test processes Error in `private$handle_error()`: ! testthat subprocess failed to start, stderr: Error: No root directory found in C:/Users//AppData/Local/Temp/RtmpcR3mjO/file9f872c131b3/rextendr.Rcheck/tests/testthat or its parent directories. Root criterion: contains a file "DESCRIPTION" In addition: Warning message: package 'testthat' was built under R version 4.2.3 Caused by error: ! R session crashed with exit code 1 Backtrace: ▆ 1. └─testthat::test_check("rextendr") 2. └─testthat::test_dir(...) 3. └─testthat:::test_files(...) 4. └─testthat:::test_files_parallel(...) 5. ├─testthat::with_reporter(...) 6. │ └─base::tryCatch(...) 7. │ └─base (local) tryCatchList(expr, classes, parentenv, handlers) 8. │ └─base (local) tryCatchOne(expr, names, parentenv, handlers[[1L]]) 9. │ └─base (local) doTryCatch(return(expr), name, parentenv, handler) 10. └─testthat:::parallel_event_loop_chunky(queue, reporters) 11. └─queue$poll(Inf) 12. └─base::lapply(...) 13. └─testthat (local) FUN(X[[i]], ...) 14. └─private$handle_error(msg, i) 15. └─rlang::abort(...) Execution halted 1 error ✖ | 0 warnings ✔ | 3 notes ✖ Error: R CMD check found ERRORs Execution halted ```
Ilia-Kosenkov commented 1 year ago

This is caused by https://github.com/extendr/rextendr/blob/fc3c70d01fd987487b8f3c94f758828c68ddc916/tests/testthat/setup.R#L5

@yutannihilation , you added this (if I read the history correctly), can you explain why we need this in tests?

yutannihilation commented 1 year ago

I don't remember, but this seems the context:

https://github.com/extendr/rextendr/issues/198