extendr / rextendr

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

Unable to test `{rextendr}`: missing `libgcc_mock` #198

Closed Ilia-Kosenkov closed 2 years ago

Ilia-Kosenkov commented 2 years ago

If I execute devtools::test() for main branch, using R 4.2 on Windows, I get this. This is related to missing libgcc_eh.a library file, but it seems there is some sort of mitigation mechanism that does not work as expected. Pinging @yutannihilation.

Error in `invoke_cargo(toolchain = toolchain, specific_target = specific_target,
    dir = dir, profile = profile, quiet = quiet, use_rtools = use_rtools)`: Unable to find 'inst/libgcc_mock'. Please reinstall the rextendr package

If I create ./inst/libgcc_mock and put there libgcc_eh.a, copied from libgcc.a, then things work as expected.

yutannihilation commented 2 years ago

You need to install the package, as the error message says.

Ilia-Kosenkov commented 2 years ago

I did it, several times. But when I run tests, I run them on the repo, not the installed version of {rextendr}. The issue is resolved if I modify the contents of repository. It seems this should not be in gitignore https://github.com/extendr/rextendr/blob/05b4d4574b7f4e26fe9bc8c88df994a1001b17dc/.gitignore#L44

yutannihilation commented 2 years ago

Ah, sorry, I meant "Install and Restart" menu of RStudio. That would invoke building the package, which should give you /inst/libgcc_mock in place.

It seems this should not be in gitignore

No, it should never be included in the repository. The users have to compile libgcc*.a with their own toolchain, which might not be the same as the current Rtools42.

Ilia-Kosenkov commented 2 years ago

Ah, interesting. But this blocks the work flow of devtools::test(), which e.g. I use frequently. Can we find a way to support both scenarios?

yutannihilation commented 2 years ago

No idea, sorry. pkgbuild::compile_dll(force = TRUE) will create inst/libgcc_mock, so I thought we can call it in tests/testthat/setup.R, but it seems it crashes for unknown reason.

==> devtools::test()

ℹ Loading rextendr
ℹ Testing rextendr
Starting 2 test processes
✔ | F W S  OK | Context
⠴ [ FAIL 0 | WARN 0 | SKIP 0 | PASS 0 ] Starting up...                                                                          

Error:
! testthat subprocess failed to start, stderr:
Re-compiling rextendr

Error: System command 'Rcmd.exe' failed, exit status: 1, stdout & stderr were printed

 Stack trace:

 1. callr_startup_hook()
 2. asNamespace("testthat")$queue_process_setup(test_package = "rextendr",  ...
 3. asNamespace("testthat")$test_files_setup_state(test_dir = test_dir,  ...
 4. testthat:::source_test_setup(".", env)
 5. testthat:::source_dir(path, "^setup.*\\.[rR]$", env = env, wrap = FALSE)
 6. base:::lapply(files, source_file, env = env, chdir = chdir, wrap = wrap)
 7. testthat:::FUN(X[[i]], ...)
 8. base:::eval(exprs, env)
 9. base:::eval(exprs, env)
 10. pkgbuild::compile_dll(force = TRUE)
    C:/Users/Yutani/Documents/GitHub/re ...
 11. withr::with_makevars(compiler_flags(debug), assignment = "+=",  ...
 12. withr:::with_envvar(c(R_MAKEVARS_USER = makevars_file), { ...
 13. base:::force(code)
 14. base:::force(code)
 15. pkgbuild:::install_min(path, dest = install_dir, components = "libs",  ...
 16. pkgbuild:::rcmd_build_tools("INSTALL", c(path, paste("--library=",  ...
 17. pkgbuild:::with_build_tools({ ...
 18. withr::with_path(rtools_path(), code)
 19. base:::force(code)
 20. base:::withCallingHandlers(callr::rcmd_safe(..., env = env, spinner = FALSE ...
 21. callr::rcmd_safe(..., env = env, spinner = FALSE, show = FALSE,  ...
 22. callr:::run_r(options)
 23. base:::with(options, with_envvar(env, do.call(processx::run,  ...
 24. base:::with.default(options, with_envvar(env, do.call(processx::run,  ...
 25. base:::eval(substitute(expr), data, enclos = parent.frame())
 26. base:::eval(substitute(expr), data, enclos = parent.frame())
 27. callr:::with_envvar(env, do.call(processx::run, c(list(bin, args = real_cmd ...
 28. base:::force(code)
 29. base:::do.call(processx::run, c(list(bin, args = real_cmdargs,  ...
 30. (function (command = NULL, args = character(), error_on_status = TRUE,  ...
 31. base:::throw(new_process_error(res, call = sys.call(), echo = echo,  ...

 x System command 'Rcmd.exe' failed, exit status: 1, stdout & stderr were printed 

Caused by error:
! R session crashed with exit code 1
Backtrace:
     ▆
  1. └─devtools::test()
  2.   └─testthat::test_local(...)
  3.     └─testthat::test_dir(...)
  4.       └─testthat:::test_files(...)
  5.         └─testthat:::test_files(...)
  6.           ├─testthat::with_reporter(...)
  7.           │ └─base::tryCatch(...)
  8.           │   └─base tryCatchList(expr, classes, parentenv, handlers)
  9.           │     └─base tryCatchOne(expr, names, parentenv, handlers[[1L]])
 10.           │       └─base doTryCatch(return(expr), name, parentenv, handler)
 11.           └─testthat:::parallel_event_loop_smooth(queue, reporters)
 12.             └─queue$poll(poll_time)
 13.               └─base::lapply(...)
 14.                 └─testthat FUN(X[[i]], ...)
 15.                   └─private$handle_error(msg, i)
 16.                     └─rlang::abort(...)
Execution halted

Exited with status 1.
yutannihilation commented 2 years ago

It seems quiet = TRUE works.