System command 'make' failed. Models won't compile

Hey all,

I can’t seem to compile any models whether I’m using cmdstanr, rstan, or brms. I’m getting similar errors for cmdstanr and brms (when cmdstanr is set as the backend), so I’ll focus on those…

Here’s the code I’m running for cmdstanr:

unlocked_folder <- "path_to_whitelisted_folder_on_my_work_computer"

## data for test model
data_list <- list(N = 10, y = c(0,1,0,0,0,0,0,0,0,1))
## model code for cmdstanr
mod_string <- "
data {
   int<lower=0> N;
   int<lower=0,upper=1> y[N];
 }
 parameters {  
   real<lower=0,upper=1> p;
 }
 model {
   p ~ beta(1,1);  // uniform prior on interval 0,1
   y ~ bernoulli(p);
}
"

file <- write_stan_file(mod_string, dir= unlocked_folder )

mod <- cmdstan_model(file)

The result is…

Compiling Stan program...
Error in `(function (command = NULL, args = character(), error_on_status = TRUE, …`:
! System command 'make' failed
---
Exit status: 2
Stderr:
make: *** /c/Users/<my_username>/OneDrive: Is a directory.  Stop.
---
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 'make' failed
---
Exit status: 2
Stderr:
make: *** /c/Users/<my_username>/OneDrive: Is a directory.  Stop.
---
Backtrace:
1. cmdstanr::cmdstan_model(file)
2. CmdStanModel$new(stan_file = stan_file, exe_file = exe_file, …
3. local initialize(...)
4. self$compile(...)
5. cmdstanr:::get_cmdstan_flags("STANCFLAGS")
6. cmdstanr:::wsl_compatible_run(command = "make", args = c(paste0("print-", …
7. base::do.call(processx::run, run_args)
8. (function (command = NULL, args = character(), error_on_status = TRUE, …
9. processx:::throw(new_process_error(res, call = sys.call(), echo = echo, …

And here’s a similar error I get when trying to fit the same model with brms using cmdstanr as a backend. First the code…

options(cmdstanr_write_stan_file_dir = unlocked_folder)

brms_fit <- brm(y ~ 1, family="bernoulli", 
           data=data.frame(y = data_list$y), backend="cmdstanr")

And here’s the error:

Compiling Stan program...
Error in `(function (command = NULL, args = character(), error_on_status = TRUE, …`:
! System command 'make' failed
---
Exit status: 2
Stderr:
make: *** /c/Users/<my_username>/OneDrive: Is a directory.  Stop.
---
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 'make' failed
---
Exit status: 2
Stderr:
make: *** /c/Users/<my_username>/OneDrive: Is a directory.  Stop.
---
Backtrace:
 1. brms::brm(y ~ 1, family = "bernoulli", data = data.frame(y = data_list$y), …
 2. brms::do_call(compile_model, compile_args)
 3. brms:::eval2(call, envir = args, enclos = envir)
 4. base::eval(expr, envir, ...)
 5. base::eval(expr, envir, ...)
 6. local .fun(model = .x1, backend = .x2, threads = .x3, opencl = .x4, …
 7. local .compile_model(model, ...)
 8. brms:::eval_silent(do_call(cmdstanr::cmdstan_model, args), type = "message", …
 9. base::eval(expr, envir)
10. base::eval(expr, envir)
11. brms::do_call(cmdstanr::cmdstan_model, args)
12. brms:::eval2(call, envir = args, enclos = envir)
13. base::eval(expr, envir, ...)
14. base::eval(expr, envir, ...)
15. local .fun(stan_file = .x1)
16. CmdStanModel$new(stan_file = stan_file, exe_file = exe_file, …
17. local initialize(...)
18. self$compile(...)
19. cmdstanr:::get_cmdstan_flags("STANCFLAGS")
20. cmdstanr:::wsl_compatible_run(command = "make", args = c(paste0("print-", …
21. base::do.call(processx::run, run_args)
22. (function (command = NULL, args = character(), error_on_status = TRUE, …
23. processx:::throw(new_process_error(res, call = sys.call(), echo = echo, …

I tried rebuild_cmdstan() but it didn’t help.

I’d be grateful for any ideas from anyone about how to fix this.

Thank you.

A couple of things to check:

  • When you ran rebuild_cmdstan() did it all complete successfully?

  • Does the same error occur if you pause your OneDrive sync?

  • Does the same error occur for the example model: cmdstanr::cmdstanr_example(example = "logistic", method = "sample")

Hey @andrjohns I appreciate the response and ideas. It looks like rebuild_cmdstan() does not complete successfully. Here’s the error:

mingw32-make: *** Waiting for unfinished jobs....
mingw32-make: *** [stan/lib/stan_math/make/libraries:64: stan/lib/stan_math/lib/sundials_6.1.1/src/nvector/serial/nvector_serial.o] Error 1

I tried pausing OneDrive and retrying everything, and running the example models, and got the same errors.

For what it’s worth, check_cmdstan_toolchain(fix = TRUE) outputs The C++ toolchain required for CmdStan is setup properly!

I really appreciate your help. Thank you.

Okay. I got fixated on the “OneDrive” thing because none of the files I’m running are located in OneDrive. I tried fully changing the location of OneDrive and rerunning the script and the above errors are now gone. No idea why or if it was instead fixed by some intermediate step that I don’t remember taking.

However, the model now fails with:

Compiling Stan program...
mingw32-make: *** [make/program:58: C:\SOMApps\temp_model_files\RtmpM9uTaR\model-3ef47423ed.exe] Error 1

Error: An error occurred during compilation! See the message above for more information.

Relevant discourse threads I can find with this error seem to end with the Windows user giving up on Stan, which I don’t want to do.

Is the problem potentially caused by cmdstanr trying to use a 32-bit compiler when my machine is 64-bit?

rebuild_cmdstan() still fails with

mingw32-make: *** [stan/lib/stan_math/make/libraries:64: stan/lib/stan_math/lib/sundials_6.1.1/src/nvector/serial/nvector_serial.o] Error 1
mingw32-make: *** Waiting for unfinished jobs....
mingw32-make: *** [stan/lib/stan_math/make/libraries:64: stan/lib/stan_math/lib/sundials_6.1.1/src/sundials/sundials_math.o] Error 1

After a fresh install of Rstan I can fit models! Sorry, this was a messy post and I can’t say I understand what was going on with my computer.