Successfully installed CmdStan using the C++ compiler toolchain route and a clone of the github repo (having been unable to get fresh conda env installs to work at all) into C:\ProgramData\cmdstan. Then followed all requirements to add environment variable (system) paths, including:
CMDSTAN: C:\ProgramData\cmdstan
PATH: C:\ProgramData\cmdstan\stan\lib\stan_math\lib\tbb
Opened RStudio and successfully installed cmdstanr
install.packages("cmdstanr", repos = c("https://mc-stan.org/r-packages/", getOption("repos")))
Started to follow the instructions for running the bernoulli.stan example Getting started with CmdStanR • cmdstanr, library calls worked ok:
This is cmdstanr version 0.7.0
- CmdStanR documentation and vignettes: mc-stan.org/cmdstanr
- CmdStan path: C:/ProgramData/cmdstan
- CmdStan version: 2.33.1
Then ran the command to run the bernoulli model, and got a load of error messages out, indicating one of the stan executables is not a valid Win32 application - this is on 64-bit Windows, with 64-bit stan install, running via 64-bit RStudio:
Compiling Stan program...
Error in `process_initialize(self, private, command, args, stdin, stdout, …`:
! Native call to `processx_exec` failed
Caused by error in `chain_call(c_processx_exec, command, c(command, args), pty, pty_options, …`:
! create process 'bin/stanc.exe' (system error 193, %1 is not a valid Win32 application.
) @win/processx.c:1040 (processx_exec)
Type .Last.error to see the more details.
> .Last.error
<c_error/rlib_error_3_0/rlib_error/error>
Error in `process_initialize(self, private, command, args, stdin, stdout, …`:
! Native call to `processx_exec` failed
Caused by error in `chain_call(c_processx_exec, command, c(command, args), pty, pty_options, …`:
! create process 'bin/stanc.exe' (system error 193, %1 is not a valid Win32 application.
) @win/processx.c:1040 (processx_exec)
---
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_standalone_hpp(temp_stan_file, stancflags_standalone)
6. withr::with_path(c(toolchain_PATH_env_var(), tbb_path()), wsl_compatible_run(command = stanc_cmd(), …
7. base::force(code)
8. cmdstanr:::wsl_compatible_run(command = stanc_cmd(), args = c(stan_file, …
9. base::do.call(processx::run, run_args)
10. (function (command = NULL, args = character(), error_on_status = TRUE, …
11. process$new(command, args, echo_cmd = echo_cmd, wd = wd, windows_verbatim_args = windows_verbatim_args, …
12. local initialize(...)
13. processx:::process_initialize(self, private, command, args, stdin, stdout, …
14. processx:::chain_call(c_processx_exec, command, c(command, args), pty, pty_options, …
15. | base::withCallingHandlers(do.call(".Call", list(.NAME, ...)), error = function(e) { …
16. | base::do.call(".Call", list(.NAME, ...))
17. | base::.handleSimpleError(function (e) …
18. | local h(simpleError(msg, call))
19. | processx:::throw_error(err, parent = e)
Having now tried and failed to get stan to work with Julia, Python and now R, this is really starting to seem like one software package that does not want to be used. At least, by anyone running on Windows…
Operating System: Windows 11 Pro Build 22631.2861
Interface Version: cmdstanr 0.7.0, CmdStan 2.33.1