Brms with cmdstanr compilation error when using threads argument

I’m attempting to speed up model fitting by specifying the “threads” argument in brms. However, when I do so I receive the following error (at least, I think this is the only/relevant error. I find the output from compilation baffling, so I’m not sure what’s relevant):

C:/rtools43/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe
: src/cmdstan/main_threads.o:main.cpp:(.text$_ZN4stan2io15stan_csv_reader13read_metadataERSiRNS0_17stan_csv_metadataEPSo[_ZN4stan2io15stan_csv_reader13read_metadataERSiRNS0_17stan_csv_metadataEPSo]+0x15d): undefined reference to `std::istream::seekg(std::fpos<int>)'
C:/rtools43/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: src/cmdstan/main_threads.o:main.cpp:(.text$_ZN4stan2io15stan_csv_reader15read_adaptationERSiRNS0_19stan_csv_adaptationEPSo[_ZN4stan2io15stan_csv_reader15read_adaptationERSiRNS0_19stan_csv_adaptationEPSo]+0x24e): undefined reference to `std::istream::seekg(std::fpos<int>)'

C:/rtools43/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: src/cmdstan/main_threads.o:main.cpp:(.text$_ZN4stan2io15stan_csv_reader12read_samplesERSiRN5Eigen6MatrixIdLin1ELin1ELi0ELin1ELin1EEERNS0_15stan_csv_timingEPSo[_ZN4stan2io15stan_csv_reader12read_samplesERSiRN5Eigen6MatrixIdLin1ELin1ELi0ELin1ELin1EEERNS0_15stan_csv_timingEPSo]+0x1d8): undefined reference to `std::istream::seekg(std::fpos<int>)'

collect2.exe: error: ld returned 1 exit status

mingw32-make: *** [make/program:59: C:\Users\ugv4\AppData\Local\Temp\2\RtmpKgtsyt\model-6274408520a8.exe] Error 1

Error: An error occured during compilation! See the message above for more information.

I’m able to replicate this error with a simple model, as well as with my own data.

brm(Sepal.Width ~ Sepal.Length, data = iris, chains = 3, threads = 3, cores = 3, backend = 'cmdstanr')

If I remove the threads = 3 argument the model compiles and runs fine.

I’ve installed cmdstan using the Conda installation instructions for Windows 10 and am using a conda environment with reticulate to work with the package in R. I tried using rebuild_cmdstan(), but that seemed to just bork my cmdstan installation and no models would compile, so I had to reinstall cmdstan with conda.

SessionInfo:

R version 4.3.2 (2023-10-31 ucrt)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19045)

Matrix products: default


locale:
[1] LC_COLLATE=English_United States.utf8  LC_CTYPE=English_United States.utf8    LC_MONETARY=English_United States.utf8
[4] LC_NUMERIC=C                           LC_TIME=English_United States.utf8    

time zone: America/New_York
tzcode source: internal

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

other attached packages:
[1] brms_2.20.4    Rcpp_1.0.11    cmdstanr_0.6.1 dplyr_1.1.4    stringr_1.5.1  sf_1.0-14      geostan_0.5.3 

loaded via a namespace (and not attached):
  [1] DBI_1.1.3            deldir_2.0-2         gridExtra_2.3        s2_1.1.4             inline_0.3.19        rlang_1.1.2          magrittr_2.0.3      
  [8] matrixStats_1.1.0    e1071_1.7-13         compiler_4.3.2       loo_2.6.0            reshape2_1.4.4       png_0.1-8            callr_3.7.3         
 [15] vctrs_0.6.4          pkgconfig_2.0.3      wk_0.9.0             crayon_1.5.2         fastmap_1.1.1        ellipsis_0.3.2       backports_1.4.1     
 [22] utf8_1.2.4           threejs_0.3.3        promises_1.2.1       markdown_1.11        ps_1.7.5             xfun_0.41            jsonlite_1.8.7      
 [29] later_1.3.1          parallel_4.3.2       prettyunits_1.2.0    R6_2.5.1             dygraphs_1.1.1.6     stringi_1.8.2        StanHeaders_2.26.28 
 [36] reticulate_1.34.0    boot_1.3-28.1        rstan_2.32.3         knitr_1.45           zoo_1.8-12           base64enc_0.1-3      bayesplot_1.10.0    
 [43] httpuv_1.6.12        Matrix_1.6-1.1       igraph_1.5.1         tidyselect_1.2.0     rstudioapi_0.15.0    abind_1.4-5          miniUI_0.1.1.1      
 [50] codetools_0.2-19     processx_3.8.2       pkgbuild_1.4.2       plyr_1.8.9           lattice_0.21-9       tibble_3.2.1         withr_2.5.2         
 [57] shiny_1.8.0          bridgesampling_1.1-2 posterior_1.5.0      coda_0.19-4          units_0.8-4          spData_2.3.0         proxy_0.4-27        
 [64] RcppParallel_5.1.7   xts_0.13.1           pillar_1.9.0         tensorA_0.36.2       KernSmooth_2.23-22   DT_0.30              checkmate_2.3.0     
 [71] renv_1.0.3           stats4_4.3.2         shinyjs_2.1.0        distributional_0.3.2 generics_0.1.3       rprojroot_2.0.4      sp_2.1-2            
 [78] truncnorm_1.0-9      ggplot2_3.4.4        rstantools_2.3.1.1   munsell_0.5.0        scales_1.2.1         gtools_3.9.5         xtable_1.8-4        
 [85] class_7.3-22         glue_1.6.2           tools_4.3.2          signs_0.1.2          shinystan_2.6.0      colourpicker_1.3.0   mvtnorm_1.2-4       
 [92] grid_4.3.2           spdep_1.3-1          crosstalk_1.2.1      QuickJSR_1.0.8       colorspace_2.1-0     nlme_3.1-163         cli_3.6.1           
 [99] fansi_1.0.5          Brobdingnag_1.2-9    gtable_0.3.4         digest_0.6.33        classInt_0.4-10      htmlwidgets_1.6.3    farver_2.1.1        
[106] htmltools_0.5.7      lifecycle_1.0.4      here_1.0.1           mime_0.12            shinythemes_1.2.0    MASS_7.3-60