LoginSignup
2
2

More than 1 year has passed since last update.

mach-o file, but is an incompatible architecture (have (x86_64), need (arm64e)) の解決策

Posted at

実行環境

  • M1 mac
  • Rails 7.0.4
  • ruby 3.1.0

エラー内容

rails sを実行しようとすると次のようなエラーが出てきた。

$ rails s
/Users/hoge/.rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/gems/bootsnap-1.13.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require': dlopen(/Users/hoge/.rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/gems/ffi-1.15.5/lib/ffi_c.bundle, 0x0009): tried: '/Users/hoge/.rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/gems/ffi-1.15.5/lib/ffi_c.bundle' (mach-o file, but is an incompatible architecture (have (x86_64), need (arm64e))) - /Users/hoge/.rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/gems/ffi-1.15.5/lib/ffi_c.bundle (LoadError)

エラー内容から、ffiの実行ファイルがx86_64で生成されてしまっているが、本当はarm64eで生成されなければならないというのが原因だとわかった。

解決方法

以下のコマンドを実行する

sudo arch -arm64e gem install ffi

再度rails sを実行すると無事にローカルサーバーが立ち上がった。

参考

2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2