Dealing with Catalina III

Hi leomarameo7,

Can you explain the steps you followed to get it working?


Hi Jeremy,

Well, I opened OS Terminal. And then I wrote as follow:
mkdir -p ~/.R
cat <<- EOF > ~/.R/Makevars

CFLAGS=-isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk
CCFLAGS=-isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk
CXXFLAGS=-isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk
CPPFLAGS=-isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -I/usr/local/include

SHLIB_CXXLDFLAGS+=-Wl,-rpath,${R_HOME}/lib ${R_HOME}/lib/libc++abi.1.dylib
SHLIB_CXX14LDFLAGS+=-Wl,-rpath,${R_HOME}/lib ${R_HOME}/lib/libc++abi.1.dylib


1 Like

Thanks, @leomarameo7.

It looks like I’ve had success by doing the same. I can now estimate a Stan model.

I’ve been trying all kinds of combinations, so I’m not sure if I can summarize exactly what should be done. But this seems to work by:

  1. Downloading and installing the rtools package from the link in the opening message of this thread.
  2. Then open Terminal and enter the changes to the Markvars that @yuling recommended.

That seems to work, but maybe I’m overlooking something.

The strange thing, though, is that I continue to get a prompt about the installation of rtools:

And yet the models estimate if I dismiss the prompt. Dismissing the prompt will be a minor nuisance when it’s time to estimate a model, but at least I’m back in business.

It should not normally be asking you to keep reinstalling the build tools. What does it say when you do in a fresh R session

pkgbuild::has_build_tools(debug = TRUE)



First it throws the same prompt for reinstalling.

Then when I click “no”, it comes back with:

pkgbuild::has_build_tools(debug = TRUE)

What about

pkgbuild::has_compiler(debug = TRUE)


Lots of syntax, concluding with:

In file included from /Library/Frameworks/R.framework/Versions/3.6/Resources/library/StanHeaders/include/stan/math/prim/mat/fun/Eigen.hpp:4:
In file included from /Library/Frameworks/R.framework/Versions/3.6/Resources/library/RcppEigen/include/Eigen/Dense:1:
/Library/Frameworks/R.framework/Versions/3.6/Resources/library/RcppEigen/include/Eigen/Core:96:10: fatal error: 'complex' file not found
#include <complex>
3 errors generated.
make: *** [foo.o] Error 1



is 2.19.2 ?


OK. Try a

install.packages("StanHeaders", type = "source")

That seemingly took care of it. There are no more prompts to install rtools. As far I can tell, everything seems to be functioning normally. Changing the Makevars file was evidently key. Thanks to all.

Works thanks!
install.packages(“rstan”, repos = “”, dependencies = TRUE)

Adding another datapoint to this. I have Catalina, freshly installed, in a VM to test rstan.

I took the following steps:

     - Requirements: R 3.6.3; Rstudio; XQuartz
       + After XQuartz: Must log out, and back in.
     - In terminal: xcode-select --install
     - Macos-Rtools
       + Download r-macos-rtools from
       + When downloaded, click "Downloads", go to "Open in Finder"; hold CTRL and right click on macos-rtools-3.2.2.pkg; click open. Install it.
     - RStan:
       + Open R (Not Rstudio? Was crashing in the VM)
       + Run the following: install.packages("Rcpp", repos = "")
	 * Say "Yes" when prompted to install from sources.
       + Run the following: install.packages("rstan", type = "source")

And changed literally nothing else. No makevars, nothing.

It worked fine. Ran the example in rstan::stan, and it seemed fine to me. Brms also worked fine.

The .R/Makevars contains the same as (Dealing with Catalina III). Note that I did not add that, nor modify it. I assume the R tools package did (?).

That is what is supposed to happen, but Catalina fails in different ways for different people so sometimes there are more steps to get rstan working.

Is there an organized list of ‘if it fails like ____, then try ____’ anywhere? We are going to introduce Stan to students on May 4, and we want them to install it a week prior to that using a document that tells them each step, and each step to take if something goes wrong.

Have the failures been due to ‘dirty’ Makevars files (e.g., having one Makevars pre-catalina, that does not work postupgrade)?

The plan is to hope that with CRAN switching back to an XCode based toolchain for R 4.0 in late April that there won’t have to be a Dealing with Catalina V thread.

I hope there is…I’ve given up on gettin rstan to work on my Mac and am running on ubuntu.

You shouldn’t give up. I think we have gotten 100% of Macs with Catalina to work eventually, but hopefully in a couple of weeks it won’t require extra effort.


minor thing – need to match the quote types in the above

Also, in the Coatless professor’s instructions…

curl -O

apparently needs to be

curl -OL