Mac M1 dyld missing symbol called on Ruby ARM64 installation via RVM

1.4k Views Asked by At

I've been cruising along with Ruby on my trusty M1 Mac for a while now, no sweat, especially in good old x86_64 mode (installed via RVM on a Rosetta terminal). Life was good.

rvm ls
   ruby-2.7.7 [ x86_64 ]
=* ruby-3.0.5 [ arm64 ]
   ruby-3.0.6 [ x86_64 ] 

I decided to embrace the native future and install Ruby 3.0.5 in its native arm64 mode. Easy peasy, right? Wrong...

Sure, it installs without a hitch, and it even looks like it's behaving. I happily installed my Rails gems through bundle install, thinking I was in the clear. But as soon as I try toboot up my Rails app I get slapped with this delightful message:

dyld[*****]: missing symbol called

I even reinstalled libffi sith arm64 homebrew as it could be related per some instructions I found in the web but got no success on rvm reinstalls since it eventually ended up failing with the same error...

I found this related SO post but it doesn't apply to me because it was related to mysql - my project uses postgres. There's another sad, lonely StackOverflow post out there with zero answers, and it's like looking in a mirror. A sad, unsolved mirror...

I reinstalled libyaml and libffi and before reinstalling Ruby, no luck. Set the LDPFlags pointing to the ffi binaries, also no luck. I did everything I could find online and nothing solved it...

3

There are 3 best solutions below

2
smathy On

It's either some gem with a native extension (most likely) or some other lib/binary that you've installed through Rosetta.

Assuming there's no other info in the error, we'll need to try solving this with a shotgun instead of a scalpel. So I'd start by removing/reinstalling rvm entirely (in fact, I'd take this opportunity to upgrade to asdf) so you can know none of the gems with native extensions were built in Intel/Rosetta mode.

If that doesn't work, then repeat with homebrew.

0
Andy Ruiz On

I hope nobody goes through this but in case you are unlucky like me, this is how I managed to fix it:

Open an arch x86_64 terminal session and uninstall the x86_64 Homebrew alongside all its installed libs (you really need to open the terminal in x86_64 mode, otherwise the uninstall script will remove the arm64 Homebrew stuff):

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/uninstall.sh)"

Reinstall rvm now in a ARM64 terminal:

\curl -sSL https://get.rvm.io | bash

At this point the installation process should fail showing you exactly which exact dynamic library wasn't present. In my case it was libgmp

Downloading https://github.com/rvm/rvm/archive/master.tar.gz
Upgrading the RVM installation in /Users/andyruizgarramones/.rvm/
    RVM PATH line found in /Users/andyruizgarramones/.mkshrc /Users/andyruizgarramones/.profile /Users/andyruizgarramones/.bashrc.
    RVM PATH line not found for Zsh, rerun this command with '--auto-dotfiles' flag to fix it.
    RVM sourcing line found in /Users/andyruizgarramones/.profile /Users/andyruizgarramones/.bash_profile /Users/andyruizgarramones/.zlogin.
    Installing rvm gem in 2 gemsets./scripts/functions/gemset: line 134: 68320 Abort trap: 6           "${rvm_ruby_binary}" -rrubygems -e "$gem_spec" 2> /dev/null
dyld[68326]: Library not loaded: /usr/local/opt/gmp/lib/libgmp.10.dylib

You should be fine by now since you can now see what's wrong and search how to fix it. In my case, I had to reinstall gmp and also deal with cmake and pkg-config

brew reinstall gmp
brew link gmp
brew reinstall cmake
brew reinstall pkg-config && brew unlink pkg-config && brew link pkg-config
1
Georgy Yuriev On

I upgraded from Ruby 2.7.5 to Ruby 3.3.0 and got the same error. The problem was in this line

gem 'therubyracer', platform: :ruby

So I just removed it.