`devtools::load_all()` works on Mac but not on Windows for a given package

Hi! :smile:

I'm currently developing a package that uses Pascal code. Basically, the package calls the bin file (depending on the user's operating system), the bin file writes temporary files which are then parsed by R and the results are displayed to the user. This package is not intended to be on CRAN. You can find the Github repo here.

I have successfully compiled the Pascal code for Mac and Windows. I've done most of the R code on my Mac, but now I want to make sure it works well on Windows.

Everything works as expected on the Mac (local development, testing, etc.).

But when I use a Windows machine and try to load the package in development mode with devtools::load_all(), I get this error :

> devtools::load_all()
β„Ή Loading lifelihood
β„Ή Re-compiling lifelihood (debug build)
── R CMD INSTALL ───────────────────────────────────────────────────────────────────────────────────────────
─  installing *source* package 'lifelihood' ... (540ms)
   ** using staged installation
   ** libs
   no DLL was created
   ERROR: compilation failed for package 'lifelihood'
─  removing 'C:/Users/JOSEPH~1/AppData/Local/Temp/Rtmp69Fte7/devtools_install_2644390e1219/lifelihood'
Error in `(function (command = NULL, args = character(), error_on_status = TRUE, …`:
! System command 'Rcmd.exe' failed
---
Exit status: 1
stdout & stderr: <printed>
---
Type .Last.error to see the more details.
> .Last.error
<system_command_status_error/rlib_error_3_0/rlib_error/error>
Error in `(function (command = NULL, args = character(), error_on_status = TRUE, …`:
! System command 'Rcmd.exe' failed
---
Exit status: 1
stdout & stderr: <printed>
---
Backtrace:
 1. devtools::load_all()
 2. pkgload::load_all(path = path, reset = reset, recompile = recompile, …
 3. pkgbuild::compile_dll(path, quiet = quiet)
 4. pkgbuild:::withr_with_makevars(compiler_flags(debug), { …
 5. pkgbuild:::withr_with_envvar(c(R_MAKEVARS_USER = makevars_file), { …
 6. base::force(code)
 7. base::force(code)
 8. pkgbuild:::withr_with_envvar(c(DEBUG = "true"), build())
 9. base::force(code)
10. pkgbuild::build()
11. pkgbuild:::install_min(path, dest = install_dir, components = "libs", args = if (needs_clean(path)) "--preclean", …
12. pkgbuild::rcmd_build_tools("INSTALL", c(path, paste("--library=", dest, …
13. pkgbuild::with_build_tools({ …
14. pkgbuild:::withr_with_path(rtools_path(), code)
15. base::force(code)
16. base::withCallingHandlers(callr::rcmd_safe(..., env = env, spinner = FALSE, …
17. callr::rcmd_safe(..., env = env, spinner = FALSE, show = FALSE, …
18. callr:::run_r(options)
19. base::with(options, with_envvar(env, do.call(processx::run, c(list(bin, …
20. base::with.default(options, with_envvar(env, do.call(processx::run, …
21. base::eval(substitute(expr), data, enclos = parent.frame())
22. base::eval(substitute(expr), data, enclos = parent.frame())
23. callr:::with_envvar(env, do.call(processx::run, c(list(bin, args = real_cmdargs, …
24. base::force(code)
25. base::do.call(processx::run, c(list(bin, args = real_cmdargs, stdout_line_callback = real_callback(stdout), …
26. (function (command = NULL, args = character(), error_on_status = TRUE, …
27. base::throw(new_process_error(res, call = sys.call(), echo = echo, …
28. | base::signalCondition(cond)
29. (function (e) …
30. asNamespace("callr")$err$throw(e)

I was able to reproduce exactly the same bug on a VM using Parallel Desktop on my Mac.

I've tried deleting R/Rstudio/Rtools several times, but it doesn't seem to change anything. I tried with VS code first but encountered the same problem.

Operating system information :

  • MacOS Sonoma 14.6.1
  • Windows machine: windows 10
  • Virtual Machine: windows 11

I think it may be related to the fact that there are source Pascal files that it is trying to compile? But it's not necessary as I already have the correct executable files in root/src/bin/.

Any help or pointers would be much appreciated. Thanks :smile:

Does R CMD build + R CMD iNSTALL work for your package on Windows?

I've just realised that if I change the src/ directory to another name such as notsrc/, everything works perfectly.

R CMD build and R CMD INSTALL work perfectly when I use a name other than src/, but not if I keep the same name:

josephbarbier@JOSEPHBARBI4D26 CLANGARM64 /z/Desktop/Lifelihood
$ R CMD build .
* checking for file './DESCRIPTION' ... OK
* preparing 'lifelihood':
* checking DESCRIPTION meta-information ... OK
* cleaning src
* checking for LF line-endings in source and make files and shell scripts
* checking for empty or unneeded directories
* re-saving tabular files
* building 'lifelihood_0.0.0.9000.tar.gz'


josephbarbier@JOSEPHBARBI4D26 CLANGARM64 /z/Desktop/Lifelihood
$ R CMD INSTALL lifelihood_0.0.0.9000.tar.gz
* installing to library 'C:/Users/josephbarbier/AppData/Local/R/win-library/4.4'
* installing *source* package 'lifelihood' ...
** using staged installation
** libs
no DLL was created
ERROR: compilation failed for package 'lifelihood'
* removing 'C:/Users/josephbarbier/AppData/Local/R/win-library/4.4/lifelihood'

I think it tries to compile if there's an src/, even if it's not necessary/possible. Is simply changing the name a valid workaround?

The real issue is why there's an error on Windows (see above) and a warning on Mac (see below, I've just realised that this warning was related to the error I got on Windows).

On Mac:

> devtools::load_all() # load the package (to use for development mode)
β„Ή Loading lifelihood
β„Ή Re-compiling lifelihood (debug build)
── R CMD INSTALL ──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
─  installing *source* package β€˜lifelihood’ ...
   ** using staged installation
   ** libs
   Warning: no source files found
─  DONE (lifelihood)

On Windows:

> devtools::load_all() # load the package (to use for development mode)
β„Ή Loading lifelihood
β„Ή Re-compiling lifelihood (debug build)
── R CMD INSTALL ───────────────────────────────────────────────────────────────────────────────────────────
─  installing *source* package 'lifelihood' ... (540ms)
   ** using staged installation
   ** libs
   no DLL was created
   ERROR: compilation failed for package 'lifelihood'
─  removing 'C:/Users/JOSEPH~1/AppData/Local/Temp/Rtmp69Fte7/devtools_install_2644390e1219/lifelihood'
Error in `(function (command = NULL, args = character(), error_on_status = TRUE, …`:
! System command 'Rcmd.exe' failed
---
Exit status: 1
stdout & stderr: <printed>
---
Type .Last.error to see the more details.

Yes, src is supposed to contain source code that compiles into a shared library.

Of course this has nothing to do with devtools::load_all(), for the record.

The solution would therefore be to use devtools::load_all(compile = FALSE) in this type of case.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.