Fully Native M1/Apple Silicon R Setup
[This article was first published on R – rud.is, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
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 # uninstall x86_64 homebrew /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" # 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 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 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 ccache (unless you don't use ccache) brew install libxml2 ccache libgit2 unixodbc # 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 # setup java 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 # this is necessary until CRAN gets updated; the Java framework is gone from macOS Rscript -e 'install.packages("rJava",,"http://rforge.net")'
To leave a comment for the author, please follow the link and comment on their blog: R – rud.is.
R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.