こんにちは。
最近はリモートが増えたので、腰への負荷が抑えられるいい椅子が欲しい。
どうもハチマキです。
はじめに
最近MacBook Air(M1,2020)を購入したため、開発環境の構築を行いました。その時に発生したエラーの対処方法について書いていきます。
補足ですが、MacBook Air(M1,2020) の環境構築の記事をちょくちょく見ましたが、intel時と比較すると初めて出くわすエラーが多々あるみたいです。
環境
- Ruby 2.6.4
- Rails 5.2.4.4
- MacBook Air(M1,2020)
やりたいこと
bundle installを問題なく通したい
問題
bundle installを実行したことで、下記のようなエラーが発生した。
言われた通りにgem install ffi -v '1.12.2'のinstallを試みるも今後は別のエラーが発生
% bundle install --path vendor/bundler The dependency tzinfo-data (>= 0) will be unused by any of the platforms Bundler is installing for. Bundler is installing for ruby but the dependency is only for x86-mingw32, x86-mswin32, x64-mingw32, java. To add those platforms to the bundle, run `bundle lock --add-platform x86-mingw32 x86-mswin32 x64-mingw32 java`. Ignoring byebug-11.1.3 because its extensions are not built. Try: gem pristine byebug --version 11.1.3 Ignoring byebug-10.0.2 because its extensions are not built. Try: gem pristine byebug --version 10.0.2 Ignoring puma-3.12.6 because its extensions are not built. Try: gem pristine puma --version 3.12.6 Ignoring sassc-2.4.0 because its extensions are not built. Try: gem pristine sassc --version 2.4.0 Ignoring sqlite3-1.4.2 because its extensions are not built. Try: gem pristine sqlite3 --version 1.4.2 Fetching gem metadata from https://rubygems.org/.......... Using rake 13.0.1 Using concurrent-ruby 1.1.7 Using i18n 1.5.1 ・ ・ Using bootsnap 1.4.5 Fetching ffi 1.12.2 Installing ffi 1.12.2 with native extensions Gem::Ext::BuildError: ERROR: Failed to build gem native extension. ・ ・ 1 error generated. make: *** [Function.o] Error 1 make failed, exit code 2 Gem files will remain installed in /Users/user_name/development_of_app/app-hoge/vendor/ruby/2.6.0/gems/ffi-1.12.2 for inspection. Results logged to /Users/user_name/development_of_app/app-hoge/vendor/ruby/2.6.0/extensions/-darwin-20/2.6.0/ffi-1.12.2/gem_make.out An error occurred while installing ffi (1.12.2), and Bundler cannot continue. Make sure that `gem install ffi -v '1.12.2' --source 'https://rubygems.org/'` succeeds before bundling. In Gemfile: bootstrap-sass was resolved to 3.4.1, which depends on sassc was resolved to 2.4.0, which depends on ffi
言われた通りにgem install ffi -v '1.12.2'をinstallを試みる
% sudo gem install ffi -v '1.12.2' Building native extensions. This could take a while... ERROR: Error installing ffi: ERROR: Failed to build gem native extension. ・ ・ make failed, exit code 2 Gem files will remain installed in /Users/user_name/.rbenv/versions/2.6.4/lib/ruby/gems/2.6.0/gems/ffi-1.12.2 for inspection. Results logged to /Users/user_name/.rbenv/versions/2.6.4/lib/ruby/gems/2.6.0/extensions/-darwin-20/2.6.0/ffi-1.12.2/gem_make.out
原因
今回git cloneしてから環境構築を行ったこともあり、おそらくすでにあったGemfile.lockを見にいっていた
解決方法
Gemfile.lockを一度削除し、再度bundle installを実行することで解消しました。
% rm Gemfile.lock #削除 % bundle install --path vendor/bundler [DEPRECATED] The `--path` flag is deprecated because it relies on being remembered across bundler invocations, which bundler will no longer do in future versions. Instead please use `bundle config set --local path 'vendor/bundler'`, and stop using this flag Fetching gem metadata from https://rubygems.org/.......... Using rake 13.0.3 ・・ ・・ ・ Bundle complete! 39 Gemfile dependencies, 144 gems now installed. Bundled gems are installed into `./vendler/bundler` Post-install message from sass: Ruby Sass has reached end-of-life and should no longer be used. * If you use Sass as a command-line tool, we recommend using Dart Sass, the new primary implementation: https://sass-lang.com/install * If you use Sass as a plug-in for a Ruby web framework, we recommend using the sassc gem: https://github.com/sass/sassc-ruby#readme * For more details, please refer to the Sass blog: https://sass-lang.com/blog/posts/7828841