Mac Monterey on Intel Macs

Like most users I have no idea what I’m doing to get this stuff to work and I’m just cutting and pasting stuff found on the internet. I was able to get this working with the following. Not sure if the gfortran stuff is needed.

Hopefully this helps anyone else.

Notes to get working:

Also did this

Tested cpp in R via

install.packages(c("remotes", "Rcpp", "RcppArmadillo")

Saved this helloworld.cpp

#include <RcppArmadillo.h>   

// [[Rcpp::depends(RcppArmadillo)]]

// [[Rcpp::export]]
void hello_world() {
  Rcpp::Rcout << "Hello World!" << std::endl;  
}

// After compile, this function will be immediately called using
// the below snippet and results will be sent to the R console.

/*** R
hello_world() 
*/

Back in R test

Rcpp::sourceCpp('path/to/file/helloworld.cpp')

That showed hello_world() so I was good.

Then I followed rstan updated install at https://github.com/stan-dev/rstan/pull/887

5 Likes

Anecdotally, the Monterey upgrade will break git and also break docker for mac. It’ll prompt you how to fix git the next time you attempt to run a git command in the terminal (fix was probably xcode command line tools install?). For docker for mac, the remedy is to uninstall and reinstall the latest version & perhaps also clear and redo any custom advanced docker configuration.

2 Likes

anyone else here still on Catalina?

Yes. I probably should upgrade now that I finished a project.

Hi! I’m new to programming. When I tried to follow your steps to create the .cpp file, I met an error message from X code. It said “RcppArmadillo.h’ file not found”. How to fix it? Thank you!

New Xcode installs usually need the command-line tools to be updated. Otherwise, Monterey didn’t break Git or Stan for me (I don’t use Docker).

I’d suggest moving to cmdstanr unless you need log density or gradients or transforms directly from R. It keeps up with the Stan releases and is easier to install than RStan.

CRAN version of RStan is 2.21. GitHub install version is 2.26. Stan itself is at 2.30, so they’re 2 and 1 years behind respectively. To install the latest RStan from GitHub, see: RStan Getting Started · stan-dev/rstan Wiki · GitHub.

The reason CRAN’s behind is that new CRAN policies on dependent packages have blocked our releases when combined with their aggressive downstream consistency checking.