Installing RStan on Mojave Mac OS X -missing step on C++ toolchain

Hello, RStan community!

I am trying to install RStan on my computer but need to install C++ Toolchain first. Unfortunately, the Installer Package for macOS R toolchain doesn’t work for Mojave on Mac OS X’s yet, so I’m trying to do it manually.

I found this help page, but it’s instructions are incomplete. That is, the page tells you to first install/update XCode and agree to the user’s license by opening it (which I’ve done) but it doesn’t tell you what to do next. Any help here? What do I do next?

In a last ditch effort, I tried to use the installer package for non-Mojave Mac’s (after installing XCode myself) and it doesn’t work…

Thanks so much for any input and direction!

After you have the toolchain installed, you should just be able to do install.packages("rstan", dependencies = TRUE) and then library(rstan) followed by stan(...).

Thanks for your quick reply! Unfortunately, I can’t install the toolchain. That’s where I’m stuck :/

After installing/opening XCode, I tried to install the toolchain for non-Mojave users and it says “The Installation Failed”. So am I missing a step?

What happens with XCode for Mojave? That should work even if the clang installer does not.

I think I figured it out. It somehow did install C++ but to be honest I’m not sure which step did it. It was likely the XCode since the installer failed.

But the example models you run to make sure it’s working were spitting warnings about StanHeaders and I used the following code (here from coatless, thank you!)in the Mac Terminal to get it to run:

sudo installer -pkg \
/Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg \
-target /

This next bit of code helps so you don’t have to change Makevars

sudo touch ~/.R/Makevars && sudo echo 'CPPFLAGS="-isystem /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include"' >> ~/.R/Makevars

Again thanks bgoodri and coatless for your help!