02 Mar 2025
Could not open library, have x86_64
, need arm64
This week I re-encountered a problem that has been plaguing me for months, but I never took the time to try to debug it before now. The problem came with a really specific and confusing symptom: any time I installed a newer version of Ruby on my machine, a daily cronjob running a Ruby script would start failing. The specific error was always an FFI exception, with the exact error message FFI::DynamicLibrary.load_library: Could not open library
.
Even more mysteriously, the error message also said:
dlopen tried 'gems/llhttp-ffi-0.5.0/ext/aarch64-darwin/libllhttp-ext.bundle’ (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e' or 'arm64'))
So somehow, this library was compiled to only contain a x86_64
binary, put that binary was located in a directory for aarch64-darwin
binaries, which means it should have been the exact arm64
format that the error message claims to want!
Checking my Ruby installation just made me more confused, since my installation was compiled solely for arm64
, and shouldn’t even be able to run in x86_64
mode at all: