Error in STAN/ BRMS functions using R 3.6.2

Hi,

I had to reinstall the system and after installing brand new R 3.6.2 I am having issues while using STAN/brms on Windows 10.

After following the instructions: https://github.com/stan-dev/rstan/wiki/RStan-Getting-Started

The model fails:

‘compileCode(f, code, language = language, verbose = verbose)’:
Compilation ERROR, function(s)/method(s) not created! In file included from C:/R/R-3.6.2/library/StanHeaders/include/stan/math/prim/arr/functor/integrate_ode_rk45.hpp:17:0,
from C:/R/R-3.6.2/library/StanHeaders/include/stan/math/prim/arr.hpp:46,
from C:/R/R-3.6.2/library/StanHeaders/include/stan/math/prim/mat.hpp:344,
from C:/R/R-3.6.2/library/StanHeaders/include/stan/math/rev/mat.hpp:12,
from C:/R/R-3.6.2/library/StanHeaders/include/stan/math.hpp:4,
from C:/R/R-3.6.2/library/StanHeaders/include/src/stan/model/model_header.hpp:4,
from file4b182f9b57cd.cpp:8:
C:/R/R-3.6.2/library/BH/include/boost/numeric/odeint.hpp:31:76: fatal error: boost/numeric/odeint/stepper/runge_kutta_cash_karp54_classic.hpp: No such file or directory
#include <boost/numeric/odeint/stepper/runge_kutta_cash_karp54_classic.hpp>

EDIT:

system(“g++ -v”) results in 127

1 Like

I’m having the same issue on Windows 10. I wonder if it is related to this change in R 3.6.2:

Windows

  • The default standard for C++ in package installation is C++11 (as it has been on other platforms where available since R 3.6.0: the default toolchain on Windows was defaulting to C++98).

DEPRECATED AND DEFUNCT

  • Support for specifying C++98 in package installation is deprecated.
  • Support in R CMD config for F77, FCPIFCPLAGS, CPP, CXXCPP and CXX98 and similar is deprecated. (CPP is found from the system make and may well not be set.) Use $CC -E and $CXX -E instead of CPP and CXXCPP.

My C++ toolchain configuration is:

CXX14=$(BINPREF)g++ -O2
CXX14FLAGS=-O3
CXX11FLAGS=-O3 

Perhaps some of this needs to change?

This is a BH bug. Do

install.packages("BH", type = "win.binary")
2 Likes

This fixed it! Hopefully the next BH release will address the issue.

Thank you, @bgoodri ! It worked on my home PC, gotta try it out @ work. :)

@bgoodri Still getting an error after installing BH, any pointers?

install.packages(“BH”, type = “win.binary”)
Installing package into ‘C:/Users/Cucumber15/Documents/R/win-library/3.6’
(as ‘lib’ is unspecified)
trying URL ‘https://cran.rstudio.com/bin/windows/contrib/3.6/BH_1.72.0-1.zip
Content type ‘application/zip’ length 18170647 bytes (17.3 MB)
downloaded 17.3 MB

package ‘BH’ successfully unpacked and MD5 sums checked

The downloaded binary packages are in
C:\Users\Cucumber15\AppData\Local\Temp\Rtmp6jeg17\downloaded_packages

fit ← stan(file = ‘8schools.stan’, data = schools_dat)
Error in compileCode(f, code, language = language, verbose = verbose) :
Compilation ERROR, function(s)/method(s) not created! In file included from C:/Users/Cucumber15/Documents/R/win-library/3.6/StanHeaders/include/stan/math/prim/arr/functor/integrate_ode_rk45.hpp:17:0,
from C:/Users/Cucumber15/Documents/R/win-library/3.6/StanHeaders/include/stan/math/prim/arr.hpp:46,
from C:/Users/Cucumber15/Documents/R/win-library/3.6/StanHeaders/include/stan/math/prim/mat.hpp:344,
from C:/Users/Cucumber15/Documents/R/win-library/3.6/StanHeaders/include/stan/math/rev/mat.hpp:12,
from C:/Users/Cucumber15/Documents/R/win-library/3.6/StanHeaders/include/stan/math.hpp:4,
from C:/Users/Cucumber15/Documents/R/win-library/3.6/StanHeaders/include/src/stan/model/model_header.hpp:4,
from file3d787ed77a85.cpp:8:
C:/Users/Cucumber15/Documents/R/win-library/3.6/BH/include/boost/numeric/odeint.hpp:31:76: fatal error: boost/numeric/odeint/stepper/runge_kutta_cash_karp54_clas
In addition: Warning message:
In system(cmd, intern = !verbose) :
running command ‘C:/PROGRA~1/R/R-36~1.2/bin/x64/R CMD SHLIB file3d787ed77a85.cpp 2> file3d787ed77a85.cpp.err.txt’ had status 1
Error in sink(type = “output”) : invalid connection

@majormongoose @bgoodri
I ran into the same issue mid model tuning now. Seems ‘BH’ pushed an update today and that must have broken it?

I removed it and installed an old version and that fixed it for me:

remove.packages(“BH”)
require(devtools)
install_version(“BH”, version = “1.69.0-1”, repos = “http://cran.us.r-project.org”)

I would do

remotes::install_github("eddelbuettel/bh")
1 Like

This one worked wow, thank you so much!

Another weird thing is now that I can fit the 8 schools example is that I got a divergent transition warning. I just ran the line a few times and it went away however.

MCMC is not deterministic (without a fixed seed), so sometimes you get a divergent transition or two and sometimes you don’t. All the more reason to run at least four chains.

I see, weird that isn’t in the quick start guide. Although I am a complete novice so… Thanks so much again!

BH 1.72.0-2 is now on CRAN and has the fix

  • inst/include/boost/numeric/odeint/stepper/: Correct accidental
    renaming in this directory, only rename in …/generation/

https://cran.r-project.org/web/packages/BH/ChangeLog

2 Likes

Glad this barrier is solved.