After trying to update brms cannot run model

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

if (!requireNamespace("devtools")) {
  install.packages("devtools")
}
devtools::install_github("paul-buerkner/brms")```

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

install.packages(c("StanHeaders","rstan"),type="source")

Should I go ahead and uninstall Rstan before trying this? I believe I tried your advice from another post
install.packages(c("rstan","StanHeaders"),type="source")

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

Hello @andrjohns , I recently tried to update brms and I had all the listed problems by Rokh42. However after doing all the unstalling and reinstalling procedure now I get the following error:
Error in compileCode(f, code, language = language, verbose = verbose) : C:\rtools42\x86_64-w64-mingw32.static.posix\bin/ld.exe: file30ec64267eff.o:file30ec64267eff.cpp:(.text$_ZN3tbb8internal26task_scheduler_observer_v3D0Ev[_ZN3tbb8internal26task_scheduler_observer_v3D0Ev]+0x1d): undefined reference to tbb::internal::task_scheduler_observer_v3::observe(bool)'C:\rtools42\x86_64-w64-mingw32.static.posix\bin/ld.exe: file30ec64267eff.o:file30ec64267eff.cpp:(.text$_ZN3tbb10interface623task_scheduler_observerD1Ev[_ZN3tbb10interface623task_scheduler_observerD1Ev]+0x1d): undefined reference to tbb::internal::task_scheduler_observer_v3::observe(bool)'C:\rtools42\x86_64-w64-mingw32.static.posix\bin/ld.exe: file30ec64267eff.o:file30ec64267eff.cpp:(.text$_ZN3tbb10interface623task_scheduler_observerD1Ev[_ZN3tbb10interface623task_scheduler_observerD1Ev]+0x3a): undefined reference to tbb::internal::task_scheduler_observer_v3::observe(bool)'C:\rtools42\x86_64-w64-mingw32.static.posix\bin/ld.exe: file30ec64267eff.o:file30ec64267eff.cpp:(.text$_ZN3tbb10interface
Error in sink(type = ā€œoutputā€) : invalid connection`