Presented without much commentary since I stopped once {ggrepel} and {graphlayouts} failed (RStudio doesn’t support it yet, either, which I knew).
The following steps will get you a fully working and STUPID FAST fully native ARM64 M1/Apple Silicon R setup with {tidyverse} and {rJava}.
Just remember, that if you need RStudio (or anything that links against the x86_64 R dylib) you’re going to be reverting this to get stuff done.
# Setting up ARM64 R on Apple Silicon/M1
# I'd run each section by hand, but feel free to live dangerously
# save off what you have installed in homebrew
brew list > ~/Documents/currently-installed-homebrew-formulas.txt
# uninstall x86_64 homebrew
# NOTE that in theory x86_64 and arm64 homebrew can live happily together but
# I went cheap on the SSD in the M1 Mini and wld like the space back
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/uninstall.sh)"
# make sure you unalias "brew" if you aliased it with "arch"
# need to do this in whatever shell startup script(s) you use, too
unalias brew='arch --x86_64 brew'
# install arm64 homebrew
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
# do what it says re: paths
# install wget (to make sure stuff is working)
brew install wget
# place for r-libs; ty R Core & Prof Ripley!
mkdir ~/Downloads/libs-arm64/
# go there
cd ~/Downloads/libs-arm64
# grab'em from https://mac.r-project.org/libs-arm64/
for dl in $(curl -sS "https://mac.r-project.org/libs-arm64/" \
| xmllint --html --xpath '//td/a[contains(@href, 'tar.gz')]/@href' 2>/dev/null - \
| sed -e 's/ href="//g' -e 's/"/\n/g'); do wget https://mac.r-project.org/libs-arm64/${dl} ; done
# prime sudo (not rly necessary but I dislike having to enter sudo passwords in a for loop)
sudo ls ~/Downloads/libs-arm64
# extract'em
for gz in $(ls ~/Downloads/libs-arm64/*gz); do
sudo tar fvxz ${gz} -C /
done
# grab r-devel
wget https://mac.r-project.org/big-sur/R-devel/arm64/R-devel.tar.gz
# extract it
tar fvxz R*.tar.gz -C /
# install libxml2 and more (to prime libraries)
brew install libxml2 ccache libgit2 unixodbc poppler coreutils
# review ~/Documents/currently-installed-homebrew-formulas.txt and add what you need from there
# put this in your shell startup (macOS folks shld get used to zsh, so ~/.zshrc is a good place to stick it at the end)
export PATH=/opt/R/arm64/bin:$PATH
# and also run it at the command prompt
export PATH=/opt/R/arm64/bin:$PATH
# go for broke!
Rscript -e "install.packages('tidyverse')"
# throw caution to the wind!
Rscript -e "install.packages('devtools')"
# shoot for the moon!
Rscript -e "install.packages(c('DBI', 'odbc'))"
# it's crazytown
Rscript -e "install.packages('ggraph')"
# ARGH! {ggrepel} and {graphlayouts} fail (RStudio won't work anyway so this whole thing was just an exercise)
# setup java; open and run the pkg installer; they have a tar.gz as well
wget https://cdn.azul.com/zulu/bin/zulu11.45.27-ca-jdk11.0.10-macosx_aarch64.dmg
# tell R about it
R CMD javareconf
# setup JAVA_HOME like you would in your shell
# this is necessary as the Java framework is gone from macOS in Big Sur
Rscript -e 'install.packages("rJava",,"http://rforge.net")'
##################################
# TO ***UNDO*** ALL OF THE ABOVE #
##################################
# uninstall amd64 homebrew
# NOTE that in theory x86_64 and arm64 homebrew can live happily together but
# I went cheap on the SSD in the M1 Mini and wld like the space back
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/uninstall.sh)"
# make sure you re-alias "brew"
# need to do this in whatever shell startup script(s) you use, too
alias brew='arch --x86_64 brew'
# install x86_64 homebrew
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
# install libxml2 and more (to prime libraries)
brew install libxml2 ccache libgit2 unixodbc poppler coreutils
# review ~/Documents/currently-installed-homebrew-formulas.txt and add what you need from there
# remove the following from your shell startup script(s)
export PATH=/opt/R/arm64/bin:$PATH
# re-setup java for x86_64; open and run the pkg installer; they have a tar.gz as well
wget "https://cdn.azul.com/zulu/bin/zulu11.45.27-ca-jdk11.0.10-macosx_x64.dmg"
# re-do the parts of the rest of the setup that you need to
Pingback: Fully Native M1/Apple Silicon R Setup – Data Science Austria
Pingback: Fully Native M1/Apple Silicon R Setup | R-bloggers
Pingback: Fully Native M1/Apple Silicon R Setup - Security Boulevard
Pingback: Fully Native M1/Apple Silicon R Setup | rud.is - Apple News
A somewhat related question. Did you by any chance ever manage to get OpenMP working in R with the m1?
Is there any way of having both setups available at the same time? From the way you have presented it, I am guessing not
That’s on the TODO for this weekend (tis a 3-day wknd in the U.S.). I think I can get it to work.