Error while installing cmdstanr version 2.24.0

If you have the chance, please also run

processx::run("g++", "--version")

Thanks @rok_cesnovar, had to set the path using set_cmdstan_path(PATH_TO_CMDSTAN).
Now, the issue is sorted.

1 Like

@rok_cesnovar I’m having the same error as the original post, only I’m using R 4.0.2 and rtools40. I’m able to compile packages from source with success, and got through these directions with successful checks on the installed versions —
https://www.maxmantei.com/2020/05/16/cmdstanr-windows — but install_cmdstan aborts with

mingw32-make.exe: *** [make/command:36: stan/lib/stan_math/lib/boost_1.72.0/stage/lib/libboost_program_options*.a] Error 1 mingw32-make.exe: *** Waiting for unfinished jobs....

Setting the path didn’t seem to change anything. Appreciate any assistance you can provide.

Sure, would like to hunt down the issues that cause this for some people as well:

Can you run
cat(readLines(file.path(cmdstan_default_install_path(), "cmdstan-2.24.0", "stan","lib","stan_math","lib","boost_1.72.0","bootstrap.log")), sep = "\n")

and post the output if you see any.

Sure:
###
### Using ‘gcc’ toolset.
###

C:\Users\ffuchs\Documents\.cmdstanr\cmdstan-2.24.0\stan\lib\stan_math\lib\boost_1.72.0\tools\build\src\engine>g++ -x c++ -std=c++11 -s -O3 -o b2.exe   -DNDEBUG  builtins.cpp class.cpp command.cpp compile.cpp constants.cpp cwd.cpp debug.cpp debugger.cpp execcmd.cpp execnt.cpp filent.cpp filesys.cpp frames.cpp function.cpp glob.cpp hash.cpp hcache.cpp hdrmacro.cpp headers.cpp jam.cpp jambase.cpp jamgram.cpp lists.cpp make.cpp make1.cpp md5.cpp mem.cpp modules.cpp native.cpp object.cpp option.cpp output.cpp parse.cpp pathnt.cpp pathsys.cpp regexp.cpp rules.cpp scan.cpp search.cpp strings.cpp subst.cpp sysinfo.cpp timestamp.cpp variable.cpp w32_getreg.cpp modules/order.cpp modules/path.cpp modules/property-set.cpp modules/regex.cpp modules/sequence.cpp modules/set.cpp  

C:\Users\ffuchs\Documents\.cmdstanr\cmdstan-2.24.0\stan\lib\stan_math\lib\boost_1.72.0\tools\build\src\engine>dir *.exe 
 Volume in drive C is Windows
 Volume Serial Number is A826-8EDB

 Directory of C:\Users\ffuchs\Documents\.cmdstanr\cmdstan-2.24.0\stan\lib\stan_math\lib\boost_1.72.0\tools\build\src\engine

07/29/2020  11:42 AM           449,536 b2.exe
               1 File(s)        449,536 bytes
               0 Dir(s)  359,308,570,624 bytes free

C:\Users\ffuchs\Documents\.cmdstanr\cmdstan-2.24.0\stan\lib\stan_math\lib\boost_1.72.0\tools\build\src\engine>copy /b .\b2.exe .\bjam.exe 
        1 file(s) copied.

Thanks.

You can actually start using cmdstanr now. The first compilation might take a minute but then everything should work as normal.

Try

test_model <- file.path(cmdstan_path(), "examples", "bernoulli", "bernoulli.stan")
test_data <- file.path(cmdstan_path(), "examples", "bernoulli", "bernoulli.data.json")
mod <- cmdstan_model(test_model)
fit <- mod$sample(data = test_data)

Please report back if it does or does not.

Three additional things would help me get to the bottom of this to if you have a minute to spare. I am unable to reproduce this on three Windows machines.

I require the output of the following three commands:

  • list.files(file.path(cmdstan_path(), "stan","lib","stan_math","lib","boost_1.72.0", "stage", "lib"))
  • processx::run("g++", "--version")
  • Sys.getenv("PATH")
3 Likes

Thanks. It did work, though took some time compiling and had a series of messages:

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
C:/Users/ffuchs/Documents/.cmdstanr/cmdstan-2.24.0/stan/lib/stan_math/lib/tbb_2019_U8/build/Makefile.tbb:28: CONFIG: cfg=release arch=intel64 compiler=gcc target=windows runtime=mingw8.3.0
task.o: duplicate section .rdata$_ZTIN3tbb4taskE[_ZTIN3tbb4taskE]' has different size arena.o: duplicate section .rdata$_ZTIN3tbb4taskE[_ZTIN3tbb4taskE]’ has different size
scheduler.o: duplicate section `.rdata$_ZTIN3tbb4taskE[_ZTIN3tbb4taskE]’ has different size

As far as those three commands go:

> list.files(file.path(cmdstan_path(), "stan","lib","stan_math","lib","boost_1.72.0", "stage", "lib"))
[1] "cmake"                                        "libboost_program_options-mgw83-mt-x64-1_72.a"
> processx::run("g++", "--version")
$status
[1] 0

$stdout
[1] "g++ (Built by Jeroen for the R-project) 8.3.0\r\nCopyright (C) 2018 Free Software Foundation, Inc.\r\nThis is free software; see the source for copying conditions.  There is NO\r\nwarranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\r\n\r\n"

$stderr
[1] ""

$timeout
[1] FALSE

> Sys.getenv("PATH")
[1] "C:/Users/ffuchs/Documents/.cmdstanr/cmdstan-2.24.0/stan/lib/stan_math/lib/tbb;C:/Users/ffuchs/Documents/.cmdstanr/cmdstan-2.24.0/stan/lib/stan_math/lib/tbb;C:\\rtools40\\usr\\bin;C:\\Program Files\\R\\R-4.0.2\\bin\\x64;C:\\Rtools\\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\\;C:\\Program Files\\MiKTeX 2.9\\miktex\\bin\\x64\\;C:\\Users\\ffuchs\\AppData\\Local\\Microsoft\\WindowsApps;C:\\Program Files (x86)\\GnuWin32\\bin;C:\\Program Files\\Java\\jre1.8.0_201\\bin;C:\\Program Files\\Java\\jre1.8.0_201\\;C:\\Program Files\\Java\\jre1.8.0_201\\lib;C:\\Program Files\\MSG MCE Software I10;C:\\rtools40\\usr\\bin;C:\\rtools40\\mingw64\\bin;"

Yes, if you get the error you got above, the first compilation will take a while. The messages are expected as well. Thanks!

Next compilations should now be faster.

I see where the problem is now. You have another g++ compiler installed on your system that clashes with the RTools one.

Two options:

  • remove C:\Program Files (x86)\GnuWin32\bin from PATH
  • move C:\rtools40\usr\bin and C:\rtools40\mingw64\bin before C:\Program Files (x86)\GnuWin32\bin in PATH

If you need assistance on how to remove from PATH/edit, let me know, I can help.

Also, C:\Rtools\bin is probaly also not needed anymore. I guess this is leftover from the old R install.

2 Likes

Interesting. That makes a lot of sense. I can handle the PATH issues. Appreciate you taking a look at this; sorry it was idiosyncratic to my machine and not more productive.

No reason to apologize!

You will definitely not be the last user to face such an issue.

1 Like

Just to jump in here - I’ve also had this issue, and not quite sure of a fix yet. I’m using rtools 3.5 - would you recommend upgrading to 4.0?

No need to upgrade. do you still have this issue?.

Can you post the output of Sys.getenv("PATH")

Yes, still having this issue! I work on two machines(covid) and it worked fine on the other once I updated my Path to include RBuildTools\3.5\bin, RBuildTools\3.5\mingw_64\bin, and Git\bin.

[1] “C:\Program Files\R\R-4.0.2\bin\x64;C:\RBuildTools\3.5\bin;C:\RBuildTools\3.5\mingw_64\bin;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\ProgramData\Oracle\Java\javapath;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\PuTTY\;C:\Program Files\Git\cmd;C:\Program Files\MATLAB\R2018b\bin;C:\WINDOWS\System32\OpenSSH\;C:\Program Files\Git\bin;C:\Users\apike\AppData\Local\atom\bin;%USERPROFILE%\AppData\Local\Microsoft\WindowsApps;”

Oh, so you are using R 4.0?

In that case yes, you need to install RTools 4.0. And remove RTools 3.5.

1 Like

Ok great! Yes I updated my version of R as was having issues with installing cmdstanr with 3.6.1.

Thanks!

1 Like

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.

1 Like

Thanks!

That is now also automatically found (and fixed if requested) in the github version of cmdstanr.

1 Like

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.