gem sqlite3がインストールできなかった。


os情報

Mac Mojava

bundle install しよっと

An error occurred while installing sqlite3 (1.3.13), and Bundler cannot continue.
Make sure that `gem install sqlite3 -v '1.3.13' --source 'https://rubygems.org/'` succeeds before
bundling.

じゃあ gem install sqlite3 -v '1.3.13' --source 'https://rubygems.org/' を実施しよ

ERROR:  Error installing sqlite3:
    ERROR: Failed to build gem native extension.

    current directory: /Users/#{ユーザー名}/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/sqlite3-1.3.13/ext/sqlite3
/Users/#{ユーザー名}/.rbenv/versions/2.4.1/bin/ruby -r ./siteconf20181125-2414-1pdp28o.rb extconf.rb

*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers.  Check the mkmf.log file for more details.  You may
need configuration options.

To see why this extension failed to compile, please check the mkmf.log which can be found here:

  /Users/#{ユーザー名}/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/extensions/x86_64-darwin-17/2.4.0-static/sqlite3-1.3.13/mkmf.log

じゃあログ見ます・・・

xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun     at: /Library/Developer/CommandLineTools/usr/bin/xcrun
  • デベロッパーの権限がない?

以下を実行します!

xcode-select --install

再度実行

bundle install

Fetching sqlite3 1.3.13
Installing sqlite3 1.3.13 with native extensions
Bundle complete! 5 Gemfile dependencies, 18 gems now installed.
Bundled gems are installed into `./vendor/bundle`

めでたしめでたし!