The R Toolchain installer doesn't seem to work but we have had success with manual installation as follows.
-
Uninstall the toolchain following here: https://thecoatlessprofessor.com/programming/r/uninstalling-the-r-development-toolchain-on-macos/. You may not have the toolchain installed but go through all of these steps anyway to ensure all components are removed.
-
Next, from the Mac terminal:
sudo pkgutil --forget com.gnu.gfortran
-
Reinstall X tools. From the Mac terminal:
xcode-select --install
-
From the Mac terminal, verify installation
gcc --version
-
If you have an Intel-based Mac, get
gfortran-Intel-11.2-BigSur.dmg
orgfortran-Intel-11.2-Monterey.dmg
(depending on your version of MacOS; how to find your version) from https://github.com/fxcoudert/gfortran-for-macOS/releases and install it. It is possible that more recent versions of gfortran might also work but we haven't confirmed. It is possible that you may need an earlier version of gfortran if you have an older version of MacOS. If you have one of the new M1 (i.e. ARM) Macs, you will needgfortran-ARM-11.3-Monterey.dmg
. -
Install required binary components
pcre2
andxz
following directions here: https://cran.r-project.org/doc/manuals/r-release/R-admin.html#macOS (i.e. enter thecurl ...
andsudo tar ...
commands as listed under "For example" into the Mac terminal). -
Restart R and test that packages can be installed from source. This will install the jsonlite package as a test.
install.packages("jsonlite", type = "source")
-
The C toolchain is now installed. Continue with instructions for installing RStan.