Unable to build Ruby 3.1.1 on my Mac OS ARM-64 machine, as it tries to use x86_64 versions of some files.
I'm trying to use brew and rbenv to manage my Ruby installation. I have used several sources online to try to specify the OpenSSL and libFFI installations on my system, but something is clearly still wrong.
I'm typing:
rvm reinstall 3.1.1 --with-openssl-dir=`brew --prefix openssl`
Still getting an error.
Specifically, I get:
openssl_missing.c:24:13: error: incomplete definition of type 'struct X509_crl_st' *psig = crl->signature;
, and, later in the process, what appears to be a related error: ld: warning: ignoring file /usr/local/Cellar/libffi/3.4.4/lib/libffi.dylib, building for macOS-arm64 but attempting to link with file built for macOS-x86_64
This is after I setup my .zshrc with the lines
export LDFLAGS="-L/usr/local/opt/libffi/lib" export CPPFLAGS="-I/usr/local/opt/libffi/include" export PKG_CONFIG_PATH="/usr/local/opt/libffi/lib/pkgconfig"
,as instructed by other searches here and elsewhere.
Does anyone have any idea what to do? I imagine that Ruby 3.1.1 has been compiled by others on MacOS. At least part of the reason I'm doing this at all is because I can't install the gem for Rails.
As noted in a comment, this problem occurred because I had used a Time Machine backup from an x86_64 machine. That led to me having the wrong version of several libraries, and possibly of Homebrew itself. I had to uninstall Ruby and Homebrew, then install them again. This eventually let me even install rails, which was my desired outcome. @tadman deserves the credit on this but I wanted others with this problem to see an Answer to this question.