How to detect arm64 architecture in a Vagrantfile on a mac?

Viewed 74

I'm trying to detect that I'm on an m1 mac in a Vagrantfile, but unfortunately vagrant is being emulated so is lying to me. Not quite sure what is actually going on here, as Ruby is running natively when I just run ruby. Anyway:

uname -m in my terminal reports arm64. print `uname -m` in the Vagrantfile, however, yields x86_64.

Similarly, print `arch` yields i386.

1 Answers
sysctl -ni hw.optional.arm64

Yields 1 on arm64 hardware and empty string on Intel.


Edit: See also this answer.
You can check whether you're running under Rosetta or not with:

sysctl -n sysctl.proc_translated
Related