Oh, so you are using R 4.0?
In that case yes, you need to install RTools 4.0. And remove RTools 3.5.
Oh, so you are using R 4.0?
In that case yes, you need to install RTools 4.0. And remove RTools 3.5.
Ok great! Yes I updated my version of R as was having issues with installing cmdstanr with 3.6.1.
Thanks!
Another user facing the same issue here. I was able to get it work by following the thread here. (Aside: I love, love, love posting my error message into google and getting directed to the right discourse.mc-stan.org thread).
My issues were very similar, except with cmdstan-2.24.1. I’m pasting the results of Sys.getenv("PATH")
here in case you can spot an issue. For what it’s worth, I do have some IT restriction due to my employer which means I have to go through a few extra steps to install software.
> Sys.getenv("PATH")
“C:/Users/dhance/Documents/.cmdstanr/cmdstan-2.24.1/stan/lib/stan_math/lib/tbb;
C:/Users/dhance/Documents/.cmdstanr/cmdstan-2.24.1/stan/lib/stan_math/lib/tbb;
C:\rtools40\usr\bin;
C:\Users\dhance\Documents\R\R-4.0.2\bin\x64;
C:\WINDOWS\system32;
C:\WINDOWS;
C:\WINDOWS\System32\Wbem;
C:\WINDOWS\System32\WindowsPowerShell\v1.0\;
C:\WINDOWS\System32\OpenSSH\;
C:\Program Files (x86)\Common Files\Acronis\VirtualFile\;
C:\Program Files (x86)\Common Files\Acronis\VirtualFile64\;
C:\Program Files (x86)\Common Files\Acronis\SnapAPI\;
C:\Windows\CCM;
C:\Program Files\Git\cmd;
C:\rtools40\usr\bin;
C:\rtools40\mingw64\bin;
C:\Users\dhance\AppData\Local\Microsoft\WindowsApps;
C:\Users\dhance\AppData\Local\Programs\MiKTeX 2.9\miktex\bin\x64"”
Two things to try.
Run:
processx::run(
"pacman",
args = c("-Syu", "mingw-w64-x86_64-make","--noconfirm"),
wd = file.path(Sys.getenv("RTOOLS40_HOME"), "usr", "bin"),
error_on_status = TRUE
)
and
write('PATH="${RTOOLS40_HOME}\\usr\\bin;${RTOOLS40_HOME}\\mingw64\\bin;${PATH}"', file = "~/.Renviron", append = TRUE)
restart R/Rstudio.
Let me know if that helps.
I had the same problem. Using R 3.5.3 and Rtools 3.5.0.4. Solution was to add C:\Rtools\mingw_64\bin to the front of the path and RESTART rstudio. Originally, it was not in the path and I also had other mingw compilers.
Thanks!
That is now also automatically found (and fixed if requested) in the github version of cmdstanr.
Hi @rok_cesnovar; so I am attempting to install cmdstanr on a separate Windows machine, and running into similar issues as before:
> mingw32-make.exe: *** [make/command:40: stan/lib/stan_math/lib/boost_1.72.0/stage/lib/libboost_program_options*.a] Error 1
> mingw32-make.exe: *** Waiting for unfinished jobs....
I then attempt to compile a model, per your directions in this thread, and get this:
> cmdstanr_example("logistic")
> Compiling Stan program...
> INFO: Could not find files for the given pattern(s).
> INFO: Could not find files for the given pattern(s).
> ar: creating stan/lib/stan_math/lib/sundials_5.2.0/lib/libsundials_nvecserial.a
> ar: creating stan/lib/stan_math/lib/sundials_5.2.0/lib/libsundials_cvodes.a
> ar: creating stan/lib/stan_math/lib/sundials_5.2.0/lib/libsundials_idas.a
> ar: creating stan/lib/stan_math/lib/sundials_5.2.0/lib/libsundials_kinsol.a
> Error: An error occured during compilation! See the message above for more information.
Here’s the PATH:
C:\\Program Files\\R\\R-4.0.3\\bin\\x64; C:\\rtools40\\mingw64\\bin; C:\\rtools40\\usr\\bin; C:\\Program Files (x86)\\Common Files\\Oracle\\Java\\javapath; C:\\WINDOWS\\system32; C:\\WINDOWS; C:\\WINDOWS\\System32\\Wbem; C:\\WINDOWS\\System32\\WindowsPowerShell\\v1.0\\; C:\\WINDOWS\\System32\\OpenSSH\\;
I have attempted several rebuild_cmdstan() after path changes and get the same errors.
check_cmdstan_toolchain() also says things are setup properly.
If I attempt to run the cmdstanr_example(“logistic”) again, I get an even less helpful error:
> cmdstanr_example("logistic") Compiling Stan program... INFO: Could not find files for the given pattern(s). Error: An error occured during compilation! See the message above for more information.
I really appreciate any assistance you can provide! Recognizing that all these Windows users with weird issues probably get annoying.
Make sure you have the latest version with remotes::install_github("stan-dev/cmdstanr")
and then please run check_cmdstan_toolchain()
.
Does it show any issues? If it does, run check_cmdstan_toolchain(fix = TRUE)
, restart the session and try rebuild_cmdstan()
again.
If that does not solve it, please post what does the following command return:
cmdstan_default_install_path()
You can also try install_cmdstan(dir = "C:/test")
, creating that test
folder first. If that works, then I think this might be a common issue we need to address, just need to figure how to diagnose it beforehand (I think its the number of characters in the install path…).
This error is otherwise not a problem actually. As in, you can start using cmdstanr and it should all work. I would like to get ride of it so any feedback is welcome.
Recognizing that all these Windows users with weird issues probably get annoying
No, not at all. I think this is annoying Windows users and I want that to go away! So these reports are VERY helpful.
No issues after check_cmdstan_toolchain();
cmdstan_default_install_path() is in my Documents folder:
“C:\Users\Me\Documents/.cmdstanr”
After installing to c:/test/ directory, I get the same results:
> set_cmdstan_path("C:/test/cmdstan-2.25.0") CmdStan path set to: C:/test/cmdstan-2.25.0 > cmdstanr_example("logistic") Compiling Stan program... INFO: Could not find files for the given pattern(s). INFO: Could not find files for the given pattern(s). ar: creating stan/lib/stan_math/lib/sundials_5.2.0/lib/libsundials_nvecserial.a ar: creating stan/lib/stan_math/lib/sundials_5.2.0/lib/libsundials_cvodes.a ar: creating stan/lib/stan_math/lib/sundials_5.2.0/lib/libsundials_idas.a ar: creating stan/lib/stan_math/lib/sundials_5.2.0/lib/libsundials_kinsol.a Error: An error occured during compilation! See the message above for more information. >
Hm, this might be new. Run
file <- file.path(cmdstan_path(), "examples", "bernoulli", "bernoulli.stan")
mod <- cmdstan_model(file, quiet = FALSE, force_recompile = TRUE)
and please post the output (there will be a LOT of it).
Surprisingly little output:
> library(cmdstanr) This is cmdstanr version 0.1.3 - Online documentation and vignettes at mc-stan.org/cmdstanr - Use set_cmdstan_path() to set the path to CmdStan - Use install_cmdstan() to install CmdStan > set_cmdstan_path("c:/test/cmdstan-2.25.0") CmdStan path set to: c:/test/cmdstan-2.25.0 > file <- file.path(cmdstan_path(), "examples", "bernoulli", "bernoulli.stan") > mod <- cmdstan_model(file, quiet = FALSE, force_recompile = TRUE) Compiling Stan program... Running mingw32-make.exe "C:/WINDOWS/TEMP/Rtmp2tq42L/model-35c819c77bb7.exe" \ "STANCFLAGS += --name='bernoulli_model'" INFO: Could not find files for the given pattern(s). INFO: Could not find files for the given pattern(s). mingw32-make.exe: *** No rule to make target 'C:/WINDOWS/TEMP/Rtmp2tq42L/model-35c819c77bb7.exe'. Stop. Error: An error occured during compilation! See the message above for more information. >
… I just tried running RStudio as administrator and it is trying harder now. Will post the output when it finishes.
Yeah, this might be is a permission issue.
C:/WINDOWS/TEMP
seems like a weird location for a temp folder ( C:/Windows usually requires privileges).
Have to check if there is a way to change the location of the temp folder.
Yep, it seemed to work when run as administrator. Output is too long for posting here, but probably good to go. Issue was probably something specific to this computer again.
Thanks again for the help! Will repost if I break things again.
Thanks. Do report back.
Will add a check for this case also. I find it weird the temp location is in C:/Windows.
Yeah it was specified in one of the system environmental variables. Changed it to my user folder; not sure how many other folks will have this problem.
Adding a check in check_cmdstan_toolchain()
: should help us here: Add a check that the user has permission in the install and temporary folder · Issue #338 · stan-dev/cmdstanr · GitHub
Was not aware this could happen at all. So thanks for tracking this down.
What is the environment variable named?
It was one of the system (not user) variables, called TEMP and TMP. Both were set to C:/WINDOWS/TEMP, which, yeah, is weird. Not sure how that happened or why.
edit I am now cooking with gas, thanks again!
Just had the exact same output, but my TEMP variable was OK. I resolved it by allowing longer paths (as described at "failed text-action" when installing CmdStan via CmdStanR). So just adding here to let others find this and maybe for @rok_cesnovar to add a check for this into check_cmdstan_toolchain()
…