Run CLI on M1 mac meant for x86_64

1.3k views Asked by At

I am on an M1 mac and am trying to download and run a project that is meant for x86_64. I opened my terminal and put it into x86_64 mode using env /usr/bin/arch -x86_64 /bin/zsh --login. I then installed the required dependencies and tried to run it yarn start. I get the following error

Error: dlopen(//ExpressLRS-Configurator/src/node_modules/@serialport/bindings/build/Release/bindings.node, 0x0001): tried: '//ExpressLRS-Configurator/src/node_modules/@serialport/bindings/build/Release/bindings.node' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e')), '/usr/local/lib/bindings.node' (no such file), '/usr/lib/bindings.node' (no such file)`

So obviously the issue is some architecture issue. My confusion is what is needing the arm64 build, shouldn't everything be in the project be expecting x86. I am both looking for some clarification into navigating x86/arm complications during development cause I have run into issues like this quite a few times and also any direct solutions to this issue.

Code Base

1

There are 1 answers

0
beeselmane On

I'm not entirely sure what exactly you're working on, but Rosetta 2 does not allowing mixing of AArch64 and x86_64 code in the same process. That's likely what's happening here, as dlopen is used to open dynamic libraries at runtime. I would guess that there is a native AArch64 binary somewhere that is attempting to load a library, but the library is available only for x86_64. As such, this would be a native process, so Rosetta would not be able to be invoked, and the process would simply crash.

Also, as another note, you don't need to run the x86_64 binary of your shell to run x86_64 programs. The operating system is able to natively detect when a binary is available only in x86_64 and will transparently invoke Rosetta 2 to execute it. In fact, I would advise against running the x86_64 binary for zsh without reason.

Note: See here for information about Rosetta 2.