Brms package in R producing nullptr_t error with Clang when compiling C++ on macOS Ventura

I’m running a Bayesian ordinal regression model using the brms package in R on a macOS Ventura 13.4 system with arm64 architecture. My Xcode and command line tools version is 14.3.1 and my Clang version is 14.0.3.

My code is as follows:

library(brms)

# Ordinal regression modeling patient's rating of inhaler instructions
# category specific effects are estimated for variable 'treat'
fit2 <- brm(rating ~ period + carry + cs(treat),
            data = inhaler, family = sratio("logit"),
            prior = set_prior("normal(0,5)"), chains = 2)

When I run this code, I encounter the following error message:

/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/__memory/unique_ptr.h:610:45: error: unknown type name 'nullptr_t'operator!=(const unique_ptr<_T1, _D1>& __x, nullptr_t) _NOEXCEPT ^fatal error: too many errors emitted, stopping now [-ferror-limit=]20 errors generated.make: *** [filece0d13588f5.o] Error 1
Error in sink(type = "output") : invalid connection

I believe the error is coming from the C++ code that brms is trying to compile, but I’m unsure how to proceed.

I have tried a number of solutions with no luck, including those suggested in these SF threads:

Does anyone know why this error might be occurring and how I might resolve it? Any help would be much appreciated.

My session information is as follows:

R version 4.3.0 (2023-04-21)
Platform: aarch64-apple-darwin20 (64-bit)
Running under: macOS Ventura 13.4

Matrix products: default
BLAS:   /Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/lib/libRblas.0.dylib 
LAPACK: /Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/lib/libRlapack.dylib;  LAPACK version 3.11.0

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

time zone: Europe/London
tzcode source: internal

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

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

loaded via a namespace (and not attached):
 [1] gtable_0.3.3         tensorA_0.36.2       ggplot2_3.4.2        shinyjs_2.1.0        htmlwidgets_1.6.2    processx_3.8.1      
 [7] inline_0.3.19        lattice_0.21-8       callr_3.7.3          crosstalk_1.2.0      vctrs_0.6.2          tools_4.3.0         
[13] ps_1.7.5             generics_0.1.3       stats4_4.3.0         parallel_4.3.0       tibble_3.2.1         fansi_1.0.4         
[19] xts_0.13.1           pkgconfig_2.0.3      Matrix_1.5-4         checkmate_2.2.0      distributional_0.3.2 RcppParallel_5.1.7  
[25] lifecycle_1.0.3      compiler_4.3.0       farver_2.1.1         stringr_1.5.0        Brobdingnag_1.2-9    munsell_0.5.0       
[31] threejs_0.3.3        codetools_0.2-19     httpuv_1.6.11        htmltools_0.5.5      bayesplot_1.10.0     pillar_1.9.0        
[37] later_1.3.1          crayon_1.5.2         ellipsis_0.3.2       DT_0.27              StanHeaders_2.26.26  bridgesampling_1.1-2
[43] abind_1.4-5          nlme_3.1-162         mime_0.12            posterior_1.4.1      rstan_2.21.8         gtools_3.9.4        
[49] tidyselect_1.2.0     digest_0.6.31        mvtnorm_1.1-3        stringi_1.7.12       reshape2_1.4.4       colourpicker_1.2.0  
[55] dplyr_1.1.2          fastmap_1.1.1        grid_4.3.0           colorspace_2.1-0     cli_3.6.1            magrittr_2.0.3      
[61] shinythemes_1.2.0    base64enc_0.1-3      loo_2.6.0            pkgbuild_1.4.1       utf8_1.2.3           prettyunits_1.1.1   
[67] scales_1.2.1         promises_1.2.0.1     backports_1.4.1      matrixStats_0.63.0   igraph_1.4.2         gridExtra_2.3       
[73] zoo_1.8-12           coda_0.19-4          shiny_1.7.4          miniUI_0.1.1.1       markdown_1.7         rstantools_2.3.1    
[79] rlang_1.1.1          xtable_1.8-4         glue_1.6.2           shinystan_2.6.0      dygraphs_1.1.1.6     plyr_1.8.8          
[85] R6_2.5.1