Hi, I have been going through the Statistical Rethinking book and am at the MCMC portion of the book and went to execute the code (partially shown) and am met with the following message.
m9.1 ← ulam(
-
alist(
-
log_gdp_std ~ dnorm( mu , sigma ) ,
-
mu <- a[cid] + b[cid]*( rugged_std - 0.215 ) ,
-
a[cid] ~ dnorm( 1 , 0.1 ) ,
-
b[cid] ~ dnorm( 0 , 0.3 ) ,
-
sigma ~ dexp( 1 )
-
) , data=dat_slim , chains=1 )
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, …
:
! cannot start processx process ‘bin/stanc’ (system error 2, No such file or directory) @unix/processx.c:613 (processx_exec)
Type .Last.error to see the more details.
I apologize if this is a common error but I have been unable to fix it. I am in R (latest version) and on a MacOS Sonoma. From what I can tell, I have the necessary tools on my machine (xcode, gcc, clang) though this piece is not my expertise so forgive me if this does not make a ton of sense. I have read a bunch of stuff online the last few days that mentions this part is often the most frustrating so I am hoping for some feedback or push in the right direction so that I can execute the code and make use of Stan in R. Any help is appreciated.
Thank you
not sure if this helps explain the issue better but here are my checks in R:
macrtools::is_xcode_cli_installed()
[1] FALSE
macrtools::is_gfortran_installed()
[1] TRUE
macrtools::is_xcode_app_installed()
[1] TRUE
which tells me (i think) to install x code by entering xcode-select --install in a terminal, which gives me the response below…I will keep trying things out but wanted to post this in case anyone has an idea that I am missing. Both my Xcode and R are up to date. Thanks
xcode-select: note: Command line tools are already installed. Use “Software Update” in System Settings or the softwareupdate command line interface to install updates
Hi all,
Adding some more details. Some other things I have tried…when I uninstall the xcode app, then enter macrtools:: is_xcode_installed() the response changes to TRUE but then when I put the xcode app back in, the response changes to FALSE. I’ve gone through and both my cmdstanr and rstan folders seem to be in the right directory. I have also made sure permissions were changed from ‘read’ to ‘read and write’ but still experiencing the issue. Below is the expanded error message. Any ideas? Hoping to try on a different machine this weekend to see if I have any better results but hoping maybe someone sees something I don’t.
Thanks
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, …
:
! cannot start processx process ‘bin/stanc’ (system error 2, No such file or directory) @unix/processx.c:613 (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, …
:
! cannot start processx process ‘bin/stanc’ (system error 2, No such file or directory) @unix/processx.c:613 (processx_exec)
Backtrace:
- rethinking::ulam(alist(log_gdp_std ~ dnorm(mu, sigma), mu ← a[cid] + b[cid] * …
- cmdstanr::cmdstan_model(stan_file = filex[[1]], compile = filex[[3]], cpp_options = cpp_options, …
- CmdStanModel$new(stan_file = stan_file, exe_file = exe_file, …
- local initialize(…)
- self$compile(…)
- cmdstanr:::get_standalone_hpp(temp_stan_file, stancflags_standalone)
- withr::with_path(c(toolchain_PATH_env_var(), tbb_path()), wsl_compatible_run(command = stanc_cmd(), …
- base::force(code)
- cmdstanr:::wsl_compatible_run(command = stanc_cmd(), args = c(paste0(“–o=”, …
- base::do.call(processx::run, run_args)
- (function (command = NULL, args = character(), error_on_status = TRUE, …
- process$new(command, args, echo_cmd = echo_cmd, wd = wd, windows_verbatim_args = windows_verbatim_args, …
- local initialize(…)
- processx:::process_initialize(self, private, command, args, stdin, stdout, …
- processx:::chain_call(c_processx_exec, command, c(command, args), pty, pty_options, …
- | base::withCallingHandlers(do.call(“.Call”, list(.NAME, …)), error = function(e) { …
- | base::do.call(“.Call”, list(.NAME, …))
- | base::.handleSimpleError(function (e) …
- | local h(simpleError(msg, call))
- | processx:::throw_error(err, parent = e)
other things I am hoping help bring some clarity:
- when I enter cmdstan_path() in R, I receive the correct path where the package is located
- when I enter stanc_path() in R, I receive: Error in stanc_path() : could not find function “stanc_path”
- when I enter get_stan_version() in R, I receive: Error in get_stan_version() : could not find function “get_stan_version”
Does this help explain the issue? Sorry if I am overlooking something simple or this is more a problem with my device and not Stan