nrode / Lifelihood

MIT License
2 stars 1 forks source link

load pkg on windows #40

Closed JosephBARBIERDARNAL closed 2 months ago

JosephBARBIERDARNAL commented 2 months ago

When trying to load pkg in development mode on the HP windows with devtools::load_all(), I run into:

> 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.

I was able to reproduce the error on a VM on my Mac with pretty much the same set up.

JosephBARBIERDARNAL commented 2 months ago

see: https://forum.posit.co/t/devtools-load-all-works-on-mac-but-not-on-windows-for-a-given-package/190503

JosephBARBIERDARNAL commented 2 months ago

Ok, I understand the problem and have found a solution.

When there's a src/, devtools::load_all() tries to compile the code because it's not common to distribute binary files (and not even allowed for CRAN packages).

For some reason, on Mac, devtools will just throw a warning saying it can't find the source files, whereas on Windows it will throw an error (see above).

The solution is not to call this directory src/ so that it doesn't try to recompile it.

It still weird why it just raises a warning on Mac and an error on Windows

JosephBARBIERDARNAL commented 2 months ago

an even better workaround would be to just use devtools::load_all(compile = FALSE)