Error while installing cmdstanr version 2.24.0

While installing “cmdstanr”, after the library(cmdstanr) is installed,
install_cmdstan() is throwing the following error:

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

Please help
Thanks

Hi,

this looks like the boost library failed to build. A couple of questions before I can give more advice.
What version of R do you have and what version of RTools do you use?

R version 3.6
Rtools35

Has this got something to do with path in environmental variables?

Can you print the output of

cat(readLines(file.path(cmdstan_path(), "stan","lib","stan_math","lib","boost_1.72.0","bootstrap.log")), sep = "\n")

Error: CmdStan path has not been set yet. See ?set_cmdstan_path.

How about

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")

This is some variation of the problem we have already seen with RTools 3.5 on Windows now that Cmdstan uses the Boost program options lib.

We already know a few solutions to your problem, but I would like to see if this is something new causing it.

The solutions we know so far are:

  • use R 4.0 and RTools 4.0 (this is highly recommended for Windows as you can get 40% faster compile times for free, by just setting a flag; but I understand this is not an option for everyone)
  • run the Boost build script manually (there are a few ways of doing this)

It might just be something else in PATH that is causing your problem here, as we know that Windows + Rtools 3.5 + Cmdstan 2.24.0 do work out of the box.

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;”