Brms model will not sample with threading enabled

I am unable to run brms models with cmdstan as backend.

I get no samples without threading and it won’t run at all with threading enabled.

## Required packages
library("brms")

# load & view the data
set.seed(44)
data = data.frame(
        y = round(c(
                rnorm(100,104,15)
                , rnorm(100,110,15)
        ))
        , x = factor(rep(c("A","B"),each=100))
        , z = factor(rep(c("C","D")))
)

fmla <- bf(y ~ x + z)

fit1 <- brm(fmla
           , data
           , prior = prior(normal(0, 2), class = b)
           , cores = 4
           #, backend = "rstan"
           , backend = "cmdstanr"
           , threads = threading(2)
           , chains = 4)

Results in:

Start sampling
Error in cmdstanr::read_cmdstan_csv(out$output_files(), variables = "",  : 
  Assertion on 'files' failed: No file provided.
In addition: Warning message:
No chains finished successfully. Unable to retrieve the fit.

The model runs as expected with threading commented out.


R version 4.3.0 (2023-04-21)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 22.04.2 LTS

Matrix products: default
BLAS:   /usr/lib/x86_64-linux-gnu/atlas/libblas.so.3.10.3 
LAPACK: /usr/lib/x86_64-linux-gnu/atlas/liblapack.so.3.10.3;  LAPACK version 3.10.0

locale:
 [1] LC_CTYPE=en_CA.UTF-8       LC_NUMERIC=C              
 [3] LC_TIME=en_CA.UTF-8        LC_COLLATE=en_CA.UTF-8    
 [5] LC_MONETARY=en_CA.UTF-8    LC_MESSAGES=en_CA.UTF-8   
 [7] LC_PAPER=en_CA.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=en_CA.UTF-8 LC_IDENTIFICATION=C       

time zone: America/Toronto
tzcode source: system (glibc)

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

other attached packages:
[1] brms_2.19.6 Rcpp_1.0.10


cmdstanr version is 0.5.3
cmdstan version is 2.32.2

@andrjohns found the fix on github.

After running rebuild_cmdstan(), everything is working as expected.

I clone the cmdstan repo and build locally, perhaps that caused a glitch