Fully Native M1/Apple Silicon R Setup

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"

# make sure you unalias "brew" if you aliased it with "arch"

# install arm64 homebrew
/bin/bash -c "$(curl -fsSL"

# 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
for dl in $(curl -sS "" \
  | xmllint --html --xpath '//td/a[contains(@href, 'tar.gz')]/@href' 2>/dev/null - \
  | sed -e 's/ href="//g' -e 's/"/\n/g'); do wget${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 /

# grab r-devel

# 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


# 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",,"")'

*** This is a Security Bloggers Network syndicated blog from authored by hrbrmstr. Read the original post at: