Dealing with Mojave

For the first time, getting rstan to work on Windows seems to be easier than getting it to work on the Mojave version Mac OS X. Mojave seems to affect different people in different ways. Here are the things I would try if rstan is not working:

  1. Make sure you have opened Xcode once via Spotlight to accept its license
  2. If that doesn’t work but you have a /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14. pkg, install that so it puts C++ headers back in /usr/include
  3. If that doesn’t work, rename / delete / empty the ~/.R/Makevars file to use Xcode’s clang++ rather than LLVM’s
  4. If that doesn’t work, recreate ~/.R/Makevars with a line that says CXX14FLAGS = -isystem ??? where ??? means the path to the C++ header files such as /usr/include

I don’t have a Mac so if anyone has any further suggestions, chime in.


  1. Try xcode-select --install from the Terminal app or the Terminal tab of the RStudio console

I did Step 1, then uninstalled rstan and reinstalled it, then did Step 5, and that worked for me.

I have no idea whether uninstalling rstan and reinstalling it was necessary.

I already done step 1, still doesn’t work…
Got a ‘permission denied’ when I tried step 2
Could not find a document named Makevars…
If I’m gonna create ~/.R/Makevars, in which directory should I create it?

In your home directory (that’s what the ~ stands for), which is where you are when you open a terminal.

That finally worked for me! Thanks!