Installing Homebrew on M1 Chips

Published:

I was using R for doing some work in GIS. This clashed with my recent migration from my old Intel MacBook to my new M1 Macbook because Homebrew installs differently on Intel versus M1. Here is the process I took to fix my issues.

Error in R

Error: ‘m’ is not a unit recognized by udunits or a user-defined unit

Error Installing Homebrew

(base) michelle@MacBook-Pro ~ % /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" ==> Checking for sudo access (which may request your password)... Password: ==> This script will install: /opt/homebrew/bin/brew /opt/homebrew/share/doc/homebrew /opt/homebrew/share/man/man1/brew.1 /opt/homebrew/share/zsh/site-functions/_brew /opt/homebrew/etc/bash_completion.d/brew /opt/homebrew

Press RETURN to continue or any other key to abort: ==> /usr/bin/sudo /usr/sbin/chown -R michelle:admin /opt/homebrew ==> Downloading and installing Homebrew… xcrun: error: unable to load libxcrun (dlopen(/Library/Developer/CommandLineTools/usr/lib/libxcrun.dylib, 0x0005): tried: ‘/Library/Developer/CommandLineTools/usr/lib/libxcrun.dylib’ (mach-o file, but is an incompatible architecture (have ‘x86_64’, need ‘arm64e’)), ‘/usr/lib/libxcrun.dylib’ (no such file)). Failed during: git init -q</code>

Step 1: Re-install Command Line Tools

Go to Apple Developer to download the latest Command Line Tools. Install.

Step 2: Install Homebrew in Terminal

Run the following command. For the most updated command, visit Homebrew.

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

Step 3: Configure Homebrew in Terminal

Note that following three commands will differ based on your setup. The first two lines come from the output in Step 2.

echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> /Users/michelle/.zprofile eval "$(/opt/homebrew/bin/brew shellenv)" brew bundle dump

Step 4: Install udunits2 in R

install.packages("udunits2",configure.args='--with-udunits2-include=/usr/include/udunits2')