かってにインパクトファクター

子育てサラリーマンが日々の雑多なことをつらつらと綴ってます。時々政治ネタ経済ネタコンピュータネタなどをはさみます。

rubyのsqlite3をgemからインストールするときにつまった

環境はFreeBSD 9.1-RELEASEなんですが、rbenvでrubyのバージョンを管理するようにしたついでに、rubyのバージョンもあげてみたんですが、rubyのsqlite3 gemをインストールしようとするとつまりました。

%sudo gem install sqlite3
Building native extensions with: '--with-sqlite3-lib=/usr/local/lib'
This could take a while...
ERROR: Error installing sqlite3:
ERROR: Failed to build gem native extension.

/home/*****/.rbenv/versions/2.1.2/bin/ruby extconf.rb --with-sqlite3-lib=/usr/local/lib
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.

Provided configuration options:
--with-opt-dir
--without-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=/home/*****/.rbenv/versions/2.1.2/bin/ruby
--with-sqlite3-dir
--without-sqlite3-dir
--with-sqlite3-include
--without-sqlite3-include=${sqlite3-dir}/include
--with-sqlite3-lib=${sqlite3-dir}/lib
--enable-local
--disable-local

extconf failed, exit code 1

Gem files will remain installed in /home/*****/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/sqlite3-1.3.9 for inspection.
Results logged to /home/*****/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/extensions/x86_64-freebsd-9/2.1.0-static/sqlite3-1.3.9/gem_make.out

sqlite3.hはすでにあるはず(他のバージョンのrubyでは使えているため)ので、探してみたら、

% locate sqlite3.h
/usr/local/include/sqlite3.h

とあるので、上記警告を見ながらオプションを設定したら無事インストール出来ました。

% sudo gem install sqlite3 -- --with-sqlite3-lib=/usr/local/lib --with-sqlite3-include=/usr/local/include
Building native extensions with: '--with-sqlite3-lib=/usr/local/lib --with-sqlite3-include=/usr/local/include'
This could take a while...
Successfully installed sqlite3-1.3.9
Parsing documentation for sqlite3-1.3.9
Installing ri documentation for sqlite3-1.3.9
Done installing documentation for sqlite3 after 1 seconds
1 gem installed

前はどうやってインストールしたんだろう?