Problem loading rstan from temporary location during installation

I’m unable to install rstan on macOS using g++ 11 provided from homebrew. My .R/Makevars looks like this


Using a blank Makevars uses the default clang++ which gives errors that suggest clang++ is too old. Any suggestions?

** testing if installed package can be loaded from temporary location
Error: package or namespace load failed for ‘rstan’:
 .onLoad failed in loadNamespace() for 'rstan', details:
  call: dyn.load(tbbmalloc_proxy, local = FALSE, now = TRUE)
  error: unable to load shared object '/private/var/folders/sp/vl960z2n1ys9v6k4ql3
TALLf5824fcfde91/rstan/, 10): no suitable image found.  Did find:
ALLf5824fcfde91/rstan/: not a file
ALLf5824fcfde91/rstan: not a file
Error: loading failed
Execution halted
ERROR: loading failed

Can you try installing the preview of rstan 2.27? Installed via:

remove.packages(c("StanHeaders", "rstan"))
install.packages("StanHeaders", repos = c("", getOption("repos")))
install.packages("rstan", repos = c("", getOption("repos")))