javascriptnode.jsmacosshellrosetta

Get real architecture of M1 Mac regardless of Rosetta


I need to retrieve the real architecture of a Mac regardless of if the process is running through Rosetta or not.

Right now in Node.js, process.arch returns x64 and in shell, uname -m returns x86_64.


Solution

  • Thanks to @Ouroborus, this note describes how to figure out if your app is translated.

    If it's translated:

    $ sysctl sysctl.proc_translated
    sysctl.proc_translated: 1
    

    If not:

    $ sysctl sysctl.proc_translated
    sysctl.proc_translated: 0
    

    On non-ARM Macs:

    $ sysctl sysctl.proc_translated
    sysctl: unknown oid 'sysctl.proc_translated'