After trying to update brms cannot run model

Hello, I recently tried to update brms updating using this command

if (!requireNamespace("devtools")) {

And somehow after doing this, I ended up without brms as a package.  So I had to reinstall it.  Now when I try to run any of my models I get this error message: 

"Error in compileCode(f, code, language = language, verbose = verbose) : 
  C:/rtools40/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/Users/rokhsarjl/R-4.0.3/library/rstan/lib/x64/libStanServices.a(stan_fit.o):stan_fit.cpp:(.data$_ZZN5boost4math6detail9bessel_j0IeEET_S3_E2P1[_ZZN5boost4math6detail9bessel_j0IeEET_S3_E2P1]+0x0): multiple definition of `boost::math::detail::bessel_j0<long double>(long double)::P1'; file2a6425987fe.o:file2a6425987fe.cpp:(.rdata$_ZZN5boost4math6detail9bessel_j0IeEET_S3_E2P1[_ZZN5boost4math6detail9bessel_j0IeEET_S3_E2P1]+0x0): first defined hereC:/rtools40/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/Users/rokhsarjl/R-4.0.3/library/rstan/lib/x64/libStanServices.a(stan_fit.o):stan_fit.cpp:(.data$_ZZN5boost4math6detail9bessel_j0IeEET_S3_E2QS[_ZZN5boost4math6detail9bessel_j0IeEET_S3_E2QS]+0x0): multiple definition of `boost::math::detail::bessel_j0<long double>(long double)::QS'; file2a6425987fe.o:file2a6425987fe.cpp:(.rdata$_ZZN5
In addition: Warning message:
In system(paste(CXX, ARGS), ignore.stdout = TRUE, ignore.stderr = TRUE) :
  'C:/rtools40/usr/mingw_/bin/g++' not found"  ```

Has anybody else had this issue?  I've tried multiple ways people have suggested solving it but nothing has fixed this issue.  When I load the packages rstan, brms, Rcpp I have no issues.  I'm very new to stan and brms so I'm not clear on what this error means and what caused it.  Thank you!
Working on PC, Windows 10
R version 4.0.3

You need to reinstall RStan and StanHeaders from source:

# Compile packages using all cores
Sys.setenv(MAKEFLAGS = paste0("-j",parallel::detectCores()))


Should I go ahead and uninstall Rstan before trying this? I believe I tried your advice from another post

And that ran and just came up with a lot of errors

I was thinking of going back to the instructions to install R stan and starting all over but I was afraid I might accidentally end up with duplicate files that would confuse Rstan. Sorry, and by that I mean should I go back to the beginning of the installation instructions and follow the instructions for installing Rtools
writeLines('PATH="${RTOOLS40_HOME}\\usr\\bin;${PATH}"', con = "~/.Renviron")

Can you try it and post the error you get?

I’m trying it right now and it will be hard for me to catch the whole error message because it’s still running but it appears to be going in circles over this error:

Users/rokhsarjl/R-4.0.3/library/BH/include/boost/mpl/assert.hpp:194:21: warning: unnecessary parentheses in declaration of ‘assert_arg’ [-Wparentheses]
failed ************ (Pred::************
C:/Users/rokhsarjl/R-4.0.3/library/BH/include/boost/mpl/assert.hpp:199:21: warning: unnecessary parentheses in declaration of ‘assert_not_arg’ [-Wparentheses]
failed ************ (boost::mpl::not_::************

Those are warnings from the C++ compiler, and are safe to ignore. If it doesn’t finish successfully, can you post the last 200ish lines? That should have the actual error

It actually finished and I just tested both of my models and they’re running again! Thank you so much- is there a reason that this happened? I’m pretty new to R (in addition to Stan and brms) and want to make sure I don’t do anything that could cause this to break again. Once again, thank you so much!

Great! It was caused by a recent update to the BH (Boost Headers) package. Something about the headers changed between releases, and so RStan and StanHeaders needed to be compiled against the new headers in the package

1 Like