Just gone through the annual pre-term updating of OS and software and none of the solutions suggested here and on stackexchange worked. Having finally got it working, I thought I’d leave a post in case others had the same issues as I did.
I took the following steps:
- Upgraded to Monterey 12.5
- Updated Xcode via the App Store (13.4.1)
- Xcode prompted me to download and install the command line tools (which I did)
- Updated R (4.2.1)
- Updated R studio (2022.07.01)
On opening Rstudio again, the popup message (I’m paraphrasing here) “git needs the command line tools, install now?”. I figured they were installed (I waited 15 minutes and it said it had worked), so I canceled and tried to install Rstan following the instructions.
First, the MacOS toolchain failed to install but elsewhere on here others have said this doesn’t matter. When I tried to install.packages(“rstan”), the errors couldn’t find ‘make’ and then the popup about getting the command line tools again. This time I did try reinstalling the command line tools (a couple of times) and it didn’t work. I had the same errors compiling a simple “helloworld.cpp” detailed here.
Following the instructions to get Rcpp working here, checking which c++ compiler was there gave
(base) Daniels-MacBook-Pro:~ danielwilliamson$ gcc --version sh: line 1: 5305 Bus error: 10 /Users/danielwilliamson/Downloads/Xcode-beta.app/Contents/Developer/usr/bin/xcodebuild -sdk /Users/danielwilliamson/Downloads/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk -find gcc 2> /dev/null gcc: error: sh -c '/Users/danielwilliamson/Downloads/Xcode-beta.app/Contents/Developer/usr/bin/xcodebuild -sdk /Users/danielwilliamson/Downloads/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk -find gcc 2> /dev/null' failed with exit code 35328: (null) (errno=Invalid argument) xcode-select: Failed to locate 'gcc', requesting installation of command line developer tools.
The solution was to open Xcode, go to Preferences -> Locations
and to notice that the box next to Command Line Tools
was blank. I selected the only option Xcode 13.41.1 (13F100)
and then everything worked fine (I still needed to follow the instructions on installing gfortran from the “get Rcpp working” post linked above). I seems that this update of Xcode with Monterey does not automatically point to the command line tools after installation. The fix is much simpler than others I’ve seen so I thought worth sharing.
Rstan and brms both now work fine and we’re ready for the new academic year!