1
Help us understand the problem. What are the problem?

posted at

updated at

【Rails】Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

開発環境

Rails6.1.4
Ruby3.0.1
macOS Monterey 12.2.1


エラー内容

gem(rinku)をbundle installしようとしたら、いきなりエラーが発生してインストールできなくなった🤯

terminal
Installing rinku 2.0.6 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

current directory: /Users/apple/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/rinku-2.0.6/ext/rinku
/Users/apple/.rbenv/versions/3.0.1/bin/ruby -I /Users/apple/.rbenv/versions/3.0.1/lib/ruby/3.0.0 -r
./siteconf20220416-552-xpdj2a.rb extconf.rb
creating Makefile

current directory: /Users/apple/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/rinku-2.0.6/ext/rinku
make DESTDIR\= clean
xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at:
/Library/Developer/CommandLineTools/usr/bin/xcrun

current directory: /Users/apple/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/rinku-2.0.6/ext/rinku
make DESTDIR\=
xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at:
/Library/Developer/CommandLineTools/usr/bin/xcrun

make failed, exit code 1

Gem files will remain installed in /Users/apple/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/rinku-2.0.6 for
inspection.
Results logged to
/Users/apple/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/extensions/x86_64-darwin-20/3.0.0/rinku-2.0.6/gem_make.out

〜省略〜

An error occurred while installing rinku (2.0.6), and Bundler cannot continue.


解決方法

こちらの記事を参考にさせていただき、下記を実行

terminal
% xcode-select --install

ポップアップが出てくるので、同意してインストール✅


インストールが終わった後、再度bundle installすると無事できました〜🎉


原因

macOSアップデート後に出ることが多いらしいです。

最後に

Gem::Ext::BuildError: ERROR: Failed to build gem native extension.の解決法に関する記事が少なく、かなり苦戦したため本記事を執筆しました!
この記事が多くの悩める方に届けば幸いです🌱

Register as a new user and use Qiita more conveniently

  1. You can follow users and tags
  2. you can stock useful information
  3. You can make editorial suggestions for articles
What you can do with signing up
1
Help us understand the problem. What are the problem?