I'm on an M2 Macbook Air, running Apple's ARM-based silicon. I want CLI commands related to building my app for different platforms to work correctly and predictably, whether I run those commands from a standalone terminal like iTerm, or the integrated terminal in my IDE.
Strangely, uname
reports different CPU architecture depending on where I invoke it.
Using iTerm2:
$ uname -m
arm64
Using the integrated terminal in Visual Studio Code:
$ uname -m
x86_64
It seems like iTerm gets it right, while VSC gets it wrong.
Both terminals are using the same uname
program:
$ which uname
/usr/bin/uname
Both are running the same shell:
$ ps -p $$
# iTerm
PID TTY TIME CMD
73664 ttys001 0:00.05 /bin/bash -il
# VSC
PID TTY TIME CMD
73775 ttys002 0:00.14 /bin/bash --init-file /Users/Tom/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/contrib/terminal/browser/media/shellIntegration-bash.sh
Both list /bin/bash
. Yes, the VSC one runs that shellIntegration-bash.sh
script, but I dug through it and didn't see anything that seemed like it would change how uname
reports the CPU architecture.
Both are loading my bash profile, as evidenced by my custom PS1
being the same in both places, and I don't have other TTY config in any other files.
I later checked, and VS Code is using Rosetta, while iTerm is not.
What is going on? How can I get uname -m
to tell the truth in VS Code?
From Running uname -m Gives x86_64 On M1 Mac Mini on apple.stackexchange.com, when running uname -m
from a process that is running using Rosetta, you get "x86_64". As you later confirmed, your VS Code is running using Rosetta, and your iTerm2 is not. Try downloading the ARM (Apple Silicon) build of VS Code.
For your reference / learning purposes, that Ask Different Q&A was the first search result for me when I googled "apple silicon "uname -m"
".