Installing RStan on Mac Mohave

Having incredible difficulty installing Rstan on MacOS Mojave.— Cannot figure out how to get C++ compiler installed on RStudio.
Tried to follow some of the trouble shooting earlier but have not had success.
Do I need to use R instead?

No. But tell us what the error message is.

So this is what I tried, and this is what happened….

install.packages(“rstan”, repos = “https://cloud.r-project.org/”, dependencies = TRUE)

trying URL ‘https://cloud.r-project.org/bin/macosx/el-capitan/contrib/3.5/rstan_2.18.2.tgz

Content type ‘application/x-gzip’ length 19107931 bytes (18.2 MB)

Looks fine so far. Was there an error message?

Oh, it didn’t paste all of it, hang on…
here are the first few screen shots:


!

the last four:


Perhaps try Stan with Mojave MacOS first? Then install.packages("rstan") again. There is more advice for Mojave here: Dealing with Mojave.

Ah the main problem I see is I can’t find devtools

trying URL ‘https://cran.rstudio.com/src/contrib/devtools_2.0.1.tar.gz

Content type ‘application/x-gzip’ length 388953 bytes (379 KB)

What is the exact code to try there? I tried copying and pasting the command in that reply and just get error messages.

I also have trouble it seems with rlang.

If I remember correctly I had same problem and my issues were solved by installing headers for Xcode

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