Ulam/cmdstan errors
Lawbarnes opened this issue · 11 comments
I'm working through the book on my own, and I'm not computer savvy. It's not my generation. In eight grade, I was actually taught to use a slide rule. And didn't pursue a math field (law instead), but I'm here anyway. My problem came in Chapter 9, for first used on Stan. Any help would be appreciated.
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 (function (command = NULL, args = character(), error_on_status = TRUE, …
:
! System command 'make' failed
Exit status: 2
Stderr:
make: *** /c/Users/lbarnes/OneDrive: Is a directory. Stop.
Many times working in a OneDrive directory is not good.
Yeah, my guess too is that OneDrive is the problem, given the error message. But I have no experience with OneDrive.
Thanks. I moved the cmdstan file to a local drive then change the path with set_cmdstan_path(), but I got the same error message. I guess R keeps looking in OneDrive. Still trying to figure out how to fix that.
If you just moved the files, that won't work most likely, you need to rebuild cmdstan.
I would actually just run
cmdstanr::install_cmdstan(dir = "THE_NON_ONEDRIVE_DIRECTORY")
And run that. If that does not help, please let me know and we can debug further.
Also make sure to set your work directory to a dir outside OneDrive (I use setwd()
in an R terminal)
Thank you. I really appreciate your help. I ran
cmdstanr::install_cmdstan(dir = "THE_NON_ONEDRIVE_DIRECTORY")
And got the same error. Here's more details on the error. I don't know enough about R to decipher it. I can't tell if the error is originating in rethinking then flowing down. Honestly, I don't know what's going on.
Error in (function (command = NULL, args = character(), error_on_status = TRUE, …:
! System command 'make' failed
Exit status: 2
Stderr:
make: *** /c/Users/lbarnes/OneDrive: Is a directory. Stop.
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_o…
- CmdStanModel$new(stan_file = stan_file, exe_file = exe_file, …
- local initialize(...)
- self$compile(...)
- cmdstanr:::get_cmdstan_flags("STANCFLAGS")
- cmdstanr:::wsl_compatible_run(command = "make", args = c(paste0("print-", …
- base::do.call(processx::run, run_args)
- (function (command = NULL, args = character(), error_on_status = …
- processx:::throw(new_process_error(res, call = sys.call(), echo = echo, …
This behavior looks a lot like the one I just posted, except I'm not using OneDrive and my Cmdstan path is set to:
/Users/bardolater/.cmdstan/cmdstan-2.31.0
@bardolater I guess you've done cmdstanr::install_cmdstan(overwrite=TRUE)
?
@Lawbarnes have you asked about this at https://discourse.mc-stan.org?
Hello, I'm a coding novice and have a similar problem to Lawbarnes that I would really appreciate help with. Everything was going smoothly until R code 9.14. I've tried many different solutions posted online, including reinstalling Rstan and CmdStanR many different ways, but still no success, although the errors I get when running code 9.14 have evolved. I'm running R version 4.3.0 in Windows 11. Below is a brief summary of some of the errors I have gotten and solutions I have tried. Thanks in advance!
1st error: could not find function "ulam"
Installing Rstan via the code below (from https://github.com/stan-dev/rstan/wiki/Configuring-C---Toolchain-for-Windows) seemed to fix this:
install.packages("StanHeaders", repos = c("https://mc-stan.org/r-packages/", getOption("repos")))
install.packages("rstan", repos = c("https://mc-stan.org/r-packages/", getOption("repos")))
2nd error: CmdStan path has not been set yet. See ?set_cmdstan_path.
After trying different ways of installing CmdStanR the error changed to...
3rd error: Can't find CmdStan makefile to detect version number. Path may not point to valid installation.
After trying still other ways of installing CmdStanR the error changed to...
4th error: Rtools42 was not found but is required to run CmdStan with R version 4.3.0.
Please install Rtools42 and run cmdstanr::check_cmdstan_toolchain().
Then I added the following to PATH under System Variables:
C:\rtools43
C:\rtools43\mingw64\bin
C:\rtools43\usr\bin
C:\Users\z3389438\AppData\Local\R\win-library\4.3\cmdstanr\cmdstan-2.32.2
C:\Users\z3389438\AppData\Local\R\win-library\4.3\cmdstanr\cmdstan-2.32.2\stan\lib\stan_math\lib\tbb
And I ran the following in Rtools43 Bash (from https://discourse.mc-stan.org/t/problem-installing-cmdstan-with-r4-2-and-rtools42/28846/5)
rm -rf /var/cache/pacman/pkg/*
rm -r /etc/pacman.d/gnupg/
pacman-key --init
pacman-key --populate msys2
pacman -S msys2-keyring
pacman -Syyu
pacman -Sy mingw-w64-ucrt-x86_64-make mingw-w64-ucrt-x86_64-gcc
pacman -Syu mingw-w64-x86_64-make
5th error: 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, …
:
! Command 'mingw32-make.exe' not found @win/processx.c:982 (processx_exec)
Type .Last.error to see the more details.
.Last.error
<c_error/rlib_error_3_0/rlib_error/error>
Error inprocess_initialize(self, private, command, args, stdin, stdout, …
:
! Native call toprocessx_exec
failed
Caused by error inchain_call(c_processx_exec, command, c(command, args), pty, pty_options, …
:
! Command 'mingw32-make.exe' not found @win/processx.c:982 (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(...)
- withr::with_path(c(toolchain_PATH_env_var(), tbb_path()), run_log <- wsl_compatible_run(com…
- base::force(code)
- cmdstanr:::wsl_compatible_run(command = make_cmd(), args = c(wsl_safe_path(tmp_exe), …
- 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_ve…
- 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)
I found a solution to this problem caused by institutional use of OneDrive over at the Stan forums [https://discourse.mc-stan.org/t/system-command-make-failed-models-wont-compile/30528/18?u=stashlee00]. All I needed to do was delete the empty folder that starts with “OneDrive”:
C:\Users\first-last\OneDrive (I deleted this one which was empty)
C:\Users\first-last\OneDrive - MMC (This one had OneDrive files in it - I did not delete it)