Error when trying to create R package that involves stan, using rstantools

As I want to create an R package that uses rstan, I first tried the toy package shown in this tutorial, which explains how to use the rstantools package. However the following mistake appears when I run the function roxygen2::roxygenize() the second time:

C:\Users\ahauser\AppData\Local\Temp\cc19bxIs.s: Assembler messages:
   C:\Users\ahauser\AppData\Local\Temp\cc19bxIs.s: Fatal error: can't write 87 bytes to section .text of stanExports_lm.o: 'file too big'
   as: stanExports_lm.o: too many sections (38862)
   C:\Users\ahauser\AppData\Local\Temp\cc19bxIs.s: Fatal error: stanExports_lm.o: file too big
   make: *** [C:/PROGRA~1/R/R-42~1.0/etc/x64/Makeconf:257: stanExports_lm.o] Error 1
   ERROR: compilation failed for package 'rstanlm'
─  removing 'C:/Users/ahauser/AppData/Local/Temp/RtmpasF7nw/devtools_install_5d06aa03fb2/rstanlm'
Error in c("(function (command = NULL, args = character(), error_on_status = TRUE, ",  : 
  ! System command 'Rcmd.exe' failed

Here is what the .Last.error.trace says:

Stack trace:

 1. roxygen2::roxygenize()
 2. roxygen2:::load_code(base_path)
 3. pkgload::load_all(path, helpers = FALSE, attach_testthat = FALSE)
 4. pkgbuild::compile_dll(path, quiet = quiet)
 5. withr::with_makevars(compiler_flags(debug), assignment = "+=",  ...
 6. withr:::with_envvar(c(R_MAKEVARS_USER = makevars_file), { ...
 7. base:::force(code)
 8. base:::force(code)
 9. pkgbuild:::install_min(path, dest = install_dir, components = "libs",  ...
 10. pkgbuild:::rcmd_build_tools("INSTALL", c(path, paste("--library=",  ...
 11. pkgbuild:::with_build_tools({ ...
 12. withr::with_path(rtools_path(), code)
 13. base:::force(code)
 14. base:::withCallingHandlers(callr::rcmd_safe(..., env = env, spinner = FALSE,  ...
 15. callr::rcmd_safe(..., env = env, spinner = FALSE, show = FALSE,  ...
 16. callr:::run_r(options)
 17. base:::with(options, with_envvar(env, do.call(processx::run,  ...
 18. base:::with.default(options, with_envvar(env, do.call(processx::run,  ...
 19. base:::eval(substitute(expr), data, enclos = parent.frame())
 20. base:::eval(substitute(expr), data, enclos = parent.frame())
 21. callr:::with_envvar(env, do.call(processx::run, c(list(bin, args = real_cmdargs,  ...
 22. base:::force(code)
 23. base:::do.call(processx::run, c(list(bin, args = real_cmdargs,  ...
 24. (function (command = NULL, args = character(), error_on_status = TRUE,  ...
 25. base:::throw(new_process_error(res, call = sys.call(), echo = echo,  ...
 26. base:::signalCondition(cond)
 27. (function (e)  ...
 28. asNamespace("callr")$err$throw(e)

 x ! System command 'Rcmd.exe' failed 

I use R 4.2.0, rstantools 2.2.0 and Stan 2.26.1.

Thanks!

I encounter exactly the same error.
Guess it is a version issue?

@andrjohns @hsbadr @bgoodri