3

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)
James Z
  • 12,209
  • 10
  • 24
  • 44
Kundan Singh
  • 51
  • 1
  • 3
  • This [issue in the gRPC repository](https://github.com/grpc/grpc/issues/24846) suggest upgrading gRPC to `1.42.0` or newer. – spickermann Dec 28 '21 at 13:12
  • % rails s, /Users/../.rbenv/versions/2.4.6/lib/ruby/gems/2.4.0/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require': dlopen(/Users/kundansingh/.rbenv/versions/2.4.6/lib/ruby/gems/2.4.0/gems/grpc-1.42.0/src/ruby/lib/grpc/grpc_c.bundle, 0x0009): symbol not found in flat namespace '_gpr_asprintf' - /Users/.../.rbenv/versions/2.4.6/lib/ruby/gems/2.4.0/gems/grpc-1.42.0/src/ruby/lib/grpc/grpc_c.bundle (LoadError) now i am getting this error – Kundan Singh Dec 29 '21 at 03:05
  • I just noticed that you are running an old version of Ruby. [Ruby 2.4 reached end of life](https://www.ruby-lang.org/en/news/2020/04/05/support-of-ruby-2-4-has-ended/) beginning of 2020. That was even before Apple announce to [switch from Intel to M1](https://en.wikipedia.org/wiki/Apple_silicon). I wonder if Ruby 2.4 is actually compatible with Apple Silicon out of the box? You may want to have a look at [this answer and its comments](https://stackoverflow.com/a/69012677/2483313) which indicated that it might work in some cases. – spickermann Dec 29 '21 at 06:54

2 Answers2

2

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
Husmus
  • 841
  • 1
  • 10
  • 23
  • I don't think you need the flag `--user-install`, that will change the installation folder to `USER INSTALLATION DIRECTORY: /Users/your_user/.gem/ruby/3.0.0`, instead of, `INSTALLATION DIRECTORY: /Users/your_user/.rbenv/versions/3.0.3/lib/ruby/gems/3.0.0` – Miguel Hargreaves Pimenta May 02 '22 at 19:47
  • 1
    This did guide me in the right direction. I had a similar incompatible architecture error when I tried to run `bundle exec slather`. This resolved my issue. https://github.com/alshedivat/al-folio/issues/240 `gem uninstall nokogiri`, `bundle config set force_ruby_platform true`, `bundle install` – Francois May 25 '22 at 11:16
0

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

Bobzius
  • 188
  • 2
  • 4