Skip to content

Instantly share code, notes, and snippets.

@mi-lee
Last active July 16, 2021 16:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mi-lee/0bf66bd8f279aa41c43430e5539a72a2 to your computer and use it in GitHub Desktop.
Save mi-lee/0bf66bd8f279aa41c43430e5539a72a2 to your computer and use it in GitHub Desktop.
Install clang6 for R toolchain on macOS
# originally caused by issues installing rgdal and pgirmess
# i.e. "configuration failed for package 'rgdal'"
# Install the macOS toolchain for versions of R starting at 3.5.z.
# 1) Delete all references to clang 4
sudo rm -rf /usr/local/clang4
sudo rm -rf /usr/local/gfortran
sudo rm -rf /usr/local/bin/gfortran
sudo rm -rf /private/var/db/receipts/com.gnu.gfortran.bom
sudo rm -rf /private/var/db/receipts/com.gnu.gfortran.plist
sudo rm -rf /private/var/db/receipts/com.rbinaries.clang4.bom
sudo rm -rf /private/var/db/receipts/com.rbinaries.clang4.plist
sudo rm -rf ~/.R/Makevars
# 2) Download and install clang-6.0.0
curl -O https://cran.r-project.org/bin/macosx/tools/clang-6.0.0.pkg
sudo installer -pkg clang-6.0.0.pkg -target /
rm -rf clang-6.0.0.pkg
# 3) Run the installer for clang-6.0.0.pkg
if [ ! -e "~/.Renviron" ] ; then
touch ~/.Renviron
fi
echo 'PATH="/usr/local/clang6/bin:${PATH}"' >> ~/.Renviron
# 4) Download and run the installer for gfortran-6.1.pkg
curl -O https://cloud.r-project.org/bin/macosx/tools/gfortran-6.1.pkg
sudo installer -pkg gfortran-6.1.pkg -target /
rm -rf gfortran-6.1.pkg
# 5) Establish a symlink of gfortran into /usr/local/bin
sudo ln -s /usr/local/gfortran/bin/gfortran /usr/local/bin/gfortran
# 6) Install the package again, i.e.
install.packages("pgirmess", type="source")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment