'Error when running bundle exec rake in macOS M1

I installed all my gems using Rosetta, because I'm working with an old repository, but I can't run bundle exec rake db:create due to this error:

rails aborted! LoadError: dlopen(/Users/user/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/nokogiri-1.12.5/lib/nokogiri/nokogiri.bundle, 0x0009): 
tried: '/Users/user/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/nokogiri-1.12.5/lib/nokogiri/nokogiri.bundle' 
(mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e')) - 
/Users/user/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/nokogiri-1.12.5/lib/nokogiri/nokogiri.bundle

I'm using a mac M1 with Monterey 12.3

I tried installing nokogiri with these options:

gem install nokogiri -v '1.12.5' -- --use-system-libraries --with-iconv-dir=$(brow --prefix libiconv) --with-xml2-include=$(brow --prefix libxml2)/include/libxml2

gem install nokogiri -v '1.12.5' --user-install --platform arm64-darwin

without any luck.

Versions

  • Ruby: 2.6.5
  • Bundler: 1.17.3
  • Nokogiri: 1.12.5

Any suggestions?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source