Using cmdstanr crashing RStudio

I’ve recently updated to macOS Sonoma and started using {renv} when using cmdstanr started causing fatal errors and crashing RStudio (i.e., loading it using library(cmdstanr) or just making function calls using cmdstanr::).

After lots of trial and error, it appears to be an RStudio thing since I can run the same code using R directly. I’ve tried reinstalling as well as rebuilding CmdStan, not using {renv}, etc. without luck. I’m not sure if macOS Sonoma or some other change is causing the problem with RStudio and cmdstanr.

I wish I had more to share. Here are some specifics on my system.

This is cmdstanr version 0.6.1
- CmdStanR documentation and vignettes:
- CmdStan path: /Users/msb-mdotson23/.cmdstan/cmdstan-2.33.1
- CmdStan version: 2.33.1

R version 4.3.1 (2023-06-16) -- "Beagle Scouts"

RStudio Version: 2023.09.0+463 | Released: 2023-09-28

macOS Sonoma 14.0 (23A344)

As a bonus, I get this warning consistently:

Compiling Stan program...
ld: warning: duplicate -rpath '/Users/msb-mdotson23/.cmdstan/cmdstan-2.33.1/stan/lib/stan_math/lib/tbb' ignored

The issue appears to be resolved by rolling back to the previous version of RStudio.

RStudio Version: 2023.06.2+561 | Released: 2023-08-24

Thanks! Had the same problem and downgrading RStudio solved the problem.

# Apple M1 Max, Ventura 13.0
# RStudio version: 2023.09.1+494 | Released: 2023-10-17
# R version 4.3.1 (2023-06-16) -- "Beagle Scouts"
brm(mpg ~ cyl, mtcars, backend = 'cmdstanr')   # crashes RStudio
brm(mpg ~ cyl, mtcars)   # doesn't crash RStudio

Downgrading to previous version of RStudio solved the problem: 2023.09.0+463.pro11

# RStudio 2023.09.0+463.pro11
# in case helpful for anyone
> packageVersion("StanHeaders")
[1] ‘2.26.28’
> packageVersion("rstan")
[1] ‘2.32.3’
> packageVersion("brms")
[1] ‘2.20.5’
> packageVersion("cmdstanr")
[1] ‘’

Thank you both for reporting this. I just responded over on GitHub Latest RStudio version 2023.09.1+494 crashes cmdstanr and brms · Issue #868 · stan-dev/cmdstanr · GitHub. Short answer is I’m not sure what’s going on yet and I haven’t been able to reproduce it, but we’ll definitely look into this.