Brms in R4.2

Has anyone had an error when trying to run {brms} functions in R4.2? It requires Rtools42 which I have installed. [rethinking] functions calling cmdstan seem to work fine.

here is the model, which is taken from McElreath's Rethinking Statistics course:

b5.2 <- 
  brm(data = d, 
      family = gaussian,
      d ~ 1 + m,
      prior = c(prior(normal(0, 0.2), class = Intercept),
                prior(normal(0, 0.5), class = b),
                prior(exponential(1), class = sigma)),
      iter = 2000, warmup = 1000, chains = 4, cores = 4,
      seed = 5,
      file = "[mypath]/b05.02")

throws this error:
Error in compileCode(f, code, language = language, verbose = verbose) :
  C:\rtools42\x86_64-w64-mingw32.static.posix\bin/ld.exe: file2e8825ef5ea5.o:file2e8825ef5ea5.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: file2e8825ef5ea5.o:file2e8825ef5ea5.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: file2e8825ef5ea5.o:file2e8825ef5ea5.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: file2e8825ef5ea5.o:file2e8825ef5ea5.cpp:(.text$_ZN3tbb10interface
Error in sink(type = "output") : invalid connection
1 Like

Hi @John_Belmont I am getting exactly the same error messages when running brm_multiple function.

Mine was working smoothly until I updated R and RStudio and Rtools, I am now running into these issues. Did you have any luck finding a solution?

Instead of trying to solve the issue I just reverted to an older version of R and Rtools4

R version 4.1.3 (2022-03-10)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19043)

Matrix products: default

locale:
[1] LC_COLLATE=English_United Kingdom.1252  LC_CTYPE=English_United Kingdom.1252    LC_MONETARY=English_United Kingdom.1252
[4] LC_NUMERIC=C                            LC_TIME=English_United Kingdom.1252    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
 [1] geosphere_1.5-14   GGally_2.1.2       brms_2.17.0        Rcpp_1.0.7         RColorBrewer_1.1-3 corrplot_0.92      forcats_0.5.1     
 [8] stringr_1.4.0      dplyr_1.0.9        purrr_0.3.4        readr_2.1.2        tidyr_1.2.0        tibble_3.1.2       ggplot2_3.3.5     
[15] tidyverse_1.3.1    mice_3.14.0       

loaded via a namespace (and not attached):
  [1] colorspace_2.0-3     ellipsis_0.3.2       ggridges_0.5.3       markdown_1.1         base64enc_0.1-3      fs_1.5.2            
  [7] rstudioapi_0.13      listenv_0.8.0        farver_2.1.0         rstan_2.21.5         DT_0.22              fansi_1.0.3         
 [13] mvtnorm_1.1-3        lubridate_1.8.0      ranger_0.13.1        xml2_1.3.3           codetools_0.2-18     bridgesampling_1.1-2
 [19] knitr_1.39           shinythemes_1.2.0    bayesplot_1.9.0      jsonlite_1.8.0       broom_0.8.0          dbplyr_2.1.1        
 [25] shiny_1.7.1          compiler_4.1.3       httr_1.4.3           backports_1.4.1      assertthat_0.2.1     Matrix_1.4-0        
 [31] fastmap_1.1.0        cli_3.0.1            later_1.3.0          htmltools_0.5.2      prettyunits_1.1.1    tools_4.1.3         
 [37] igraph_1.3.1         coda_0.19-4          gtable_0.3.0         glue_1.6.2           reshape2_1.4.4       posterior_1.2.1     
 [43] cellranger_1.1.0     vctrs_0.4.1          nlme_3.1-155         crosstalk_1.2.0      tensorA_0.36.2       xfun_0.30           
 [49] globals_0.14.0       ps_1.6.0             rvest_1.0.2          mime_0.12            miniUI_0.1.1.1       lifecycle_1.0.1     
 [55] gtools_3.9.2         future_1.25.0        zoo_1.8-10           scales_1.2.0         colourpicker_1.1.1   hms_1.1.1           
 [61] promises_1.2.0.1     Brobdingnag_1.2-7    parallel_4.1.3       inline_0.3.19        shinystan_2.6.0      yaml_2.3.5          
 [67] gridExtra_2.3        StanHeaders_2.21.0-7 loo_2.5.1            reshape_0.8.9        stringi_1.7.6        dygraphs_1.1.1.6    
 [73] checkmate_2.1.0      pkgbuild_1.3.1       rlang_1.0.2          pkgconfig_2.0.3      matrixStats_0.62.0   distributional_0.3.0
 [79] evaluate_0.15        lattice_0.20-45      rstantools_2.2.0     htmlwidgets_1.5.4    tidyselect_1.1.2     processx_3.5.2      
 [85] parallelly_1.31.1    plyr_1.8.7           magrittr_2.0.3       R6_2.5.1             generics_0.1.2       DBI_1.1.2           
 [91] pillar_1.7.0         haven_2.5.0          withr_2.5.0          xts_0.12.1           sp_1.4-7             abind_1.4-5         
 [97] modelr_0.1.8         crayon_1.5.1         utf8_1.2.2           rmarkdown_2.14       tzdb_0.3.0           grid_4.1.3          
[103] readxl_1.4.0         callr_3.7.0          threejs_0.3.3        reprex_2.0.1         digest_0.6.29        xtable_1.8-4        
[109] httpuv_1.6.5         RcppParallel_5.1.4   stats4_4.1.3         munsell_0.5.0        shinyjs_2.1.0 

I was not able to use R4.2, so I also reverted to the previous version. I reverted everything back to R4.1.x since I don’t want to keep track of two different versions of R. Maybe a Windows-specific issue, but I like the convenience of running Rstudio in Windows.

1 Like

There are some known issues (and a few known workarounds) with R4.2 on Windows and Stan packages. See: Stan & R 4.2 on Windows – The Stan Blog

For some reason, R(tools) 4.2 ignores LOCAL_LIBS environment variables on Windows only. See Stan & R 4.2 on Windows - #8 by hsbadr