(mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e')) on apple M1 chip when running rake db:create
Asked Answered
B

2

6

when I try to create my database this error appear

$ rake db:create
rake aborted!
LoadError: dlopen(/Users/agonzalez/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/nokogiri-1.13.6/lib/nokogiri/nokogiri.bundle, 0x0009): tried: '/Users/agonzalez/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/nokogiri-1.13.6/lib/nokogiri/nokogiri.bundle' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e')) - /Users/agonzalez/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/nokogiri-1.13.6/lib/nokogiri/nokogiri.bundle
/Users/agonzalez/Documents/join/config/application.rb:7:in `<top (required)>'
/Users/agonzalez/Documents/join/Rakefile:4:in `require_relative'
/Users/agonzalez/Documents/join/Rakefile:4:in `<top (required)>'

Caused by:
LoadError: cannot load such file -- /Users/agonzalez/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/nokogiri-1.13.6/lib/nokogiri/2.7/nokogiri
/Users/agonzalez/Documents/join/config/application.rb:7:in `<top (required)>'
/Users/agonzalez/Documents/join/Rakefile:4:in `require_relative'
/Users/agonzalez/Documents/join/Rakefile:4:in `<top (required)>'
(See full trace by running task with --trace)

I already try

bundle config set force_ruby_platform true

My ruby version is ruby 2.7.1p83 (2020-03-31 revision a0c7c23c9c) [-darwin21]

bundle version 2.1.4

Rails version 5.2.7

Nokogiri version nokogiri-1.13.6

Briticism answered 6/7, 2022 at 23:54 Comment(0)
A
4

I was having a similar issue, ultimately what fixed it was uninstalling nokogiri and then reinstalling it with specific platform like so:

gem uninstall nokogiri

gem install nokogiri -v 1.13.6 --platform arm64-darwin

This got me up and running for the time being. I suspect it may break again if I ever do a bundle install in the future, there may be a way to fix this via editing the Gemfile but I'm not sure what that would look like.

Anticlinorium answered 13/7, 2022 at 14:26 Comment(0)
M
-1

The above answers have no effect on me. Following the steps below works for me:

  1. :bundle config --global build.ffi --enable-libffi-alloc
  2. :rm -rf ~/.bundle/vendor
Mulderig answered 22/9, 2022 at 10:45 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.