読者です 読者をやめる 読者になる 読者になる

ぼろぼろ平原

困った

Linuxbrewでsqliteを入れたのにgem install sqlite3が失敗した時の対処法

Linuxbrewsqliteを入れたあと、 $ gem install sqlite3を実行すると「sqlite3.hが見つからない」というエラーメッセージが出て失敗する。

$ gem install sqlite3
Building native extensions.  This could take a while...
ERROR:  Error installing sqlite3:
    ERROR: Failed to build gem native extension.

    current directory: /home/foo/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/sqlite3-1.3.11/ext/sqlite3
/home/foo/.rbenv/versions/2.3.1/bin/ruby -r ./siteconf20160801-29195-1vog9eq.rb extconf.rb
checking for sqlite3.h... no
sqlite3.h is missing. Try 'port install sqlite3 +universal',
'yum install sqlite-devel' or 'apt-get install libsqlite3-dev'
and check your shared library search path (the
location where your sqlite3 shared library is located).
*** 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.

そういう時は以下のようにLinuxbrewで入れたsqliteのパスを指定してあげればOK。

$ gem install sqlite3 -- --with-opt-dir=`brew --prefix sqlite`