/usr/bin/arch
A lot of us have ended up on Macs with M1 chips lately. Rosetta exists to support apps built for Intel processors. In this post I want to highlight the extended arch utility — which on Macs goes a bit beyond uname -m — and the situations where it can come in handy.
Let’s see how arch works. With no arguments it prints the current architecture. By passing an architecture name as an argument, you can pretend to be a different type of processor. What we want is to make the app we’re invoking
think it’s running on Intel:
$ arch
arm64
$ arch -arm64 uname -m
arm64
$ arch -x86_64 uname -m
x86_64
We managed to make it look like we’re running on x86_64. Now about how this might actually be applied.
Imagine a situation where some application isn’t shipped as an arm64 build. At the time of writing, that’s the case
for kustomize, for example. As you already know, I’m a big fan of asdf1 for managing pinned versions of installed apps. Let’s try to install kustomize via asdf:
$ asdf install kustomize 5.1.1
Downloading kustomize from https://github.com/kubernetes-sigs/kustomize/releases/download/kustomize%2Fv5.1.1/kustomize_v5.1.1_darwin_arm64.tar.gz
tar: Error opening archive: Unrecognized archive format
There’s actually no arm64 release for M1:
https://github.com/kubernetes-sigs/kustomize/releases/tag/kustomize%2Fv5.1.1.
Let’s use arch to fake x86_64:
❯ arch -x86_64 asdf install kustomize 5.1.1
Downloading kustomize from https://github.com/kubernetes-sigs/kustomize/releases/download/kustomize%2Fv5.1.1/kustomize_v5.1.1_darwin_amd64.tar.gz
$ asdf global kustomize 5.1.1
$ kustomize version
v5.1.1
Now we have a working utility we can use on our M1. Rosetta is what keeps it running.