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.


This issue is still occurring with cmdstanr 0.7.0 and the latest versions of RStudio (2023.09.1+494) and R (4.3.2) on my Macbook Pro M2. Rolling back to RStudio 2023.06.2+561 still resolves the issue. Is it possible this is an RStudio bug that should be reported to the RStudio team?

Edit: There’s already an RStudio github issue on this.

Sorry this is still happening! Yeah I think this is an RStudio issue (unless they can point us to something we’re doing wrong, in which case we’re happy to fix it). It seems like the problem occurred due to an rstudio update at a time when we hadn’t changed anything in cmdstanr (since then we’ve made some changes to cmdstanr, but nothing that should affect this).

This is weird: To do some more testing I reinstalled RStudio 2023.09.1+494 (the latest version) and now I’m not getting any R crashes with cmdstanr, even with the latest version of RStudio. I first started getting these crashes last week so it was reproducible on at least a few occasions. But yesterday is the first time I rolled back to an earlier RStudio version and then rolled forward to the latest version.

Thanks for following up. That does seem quite strange, although in a good way I guess. But I wish we knew what was causing this.