error: rails aborted! LoadError: dlopen(/Users...but is an incompatible architecture (have 'x86_64', need 'arm64e'))

Viewed 2606

getting error like this

rails aborted!

LoadError: dlopen(/Users/../.rbenv/versions/2.4.6/lib/ruby/gems/2.4.0/gems/grpc-1.22.0-universal-darwin/src/ruby/lib/grpc/2.4/grpc_c.bundle, 0x0009): tried: '/Users/../.rbenv/versions/2.4.6/lib/ruby/gems/2.4.0/gems/grpc-1.22.0-universal-darwin/src/ruby/lib/grpc/2.4/grpc_c.bundle' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e')), '/usr/local/lib/grpc_c.bundle' (no such file), '/usr/lib/grpc_c.bundle' (no such file) - /Users/../.rbenv/versions/2.4.6/lib/ruby/gems/2.4.0/gems/grpc-1.22.0-universal-darwin/src/ruby/lib/grpc/2.4/grpc_c.bundle

my project required me to setup these version

  • ruby v2.4.6
  • rails v5.0.7.2
  • postgres (PostgreSQL) 14.1
  • macOs:m1 chip(MacOs monterey)
2 Answers

I was getting a similar error on my macos while trying to use the nokogiri gem.

Turns out the gem was installed for the incorrect platform, as the error message says.

 > gem list | grep nokogiri 
 nokogiri (1.13.1 x86_64-darwin, 1.10.1, 1.6.2.1)

I fixed this by uninstalling the gem

gem uninstall nokogiri --version 1.13.1

and then reinstalling it with the correct platform.

gem install nokogiri --user-install --platform arm64-darwin

If you see this issue with the Nokogiri gem while trying to start your Rails app, remove

nokogiri (1.13.6-arm64-darwin)
      racc (~> 1.4)

from your Gemfile and do a bundle install

Related