Measure Once, Cut Twice

Notes on MacRuby and sqlite3

Posted in macruby, ruby by steve on April 10, 2011

Each time I install the latest version of MacRuby, I spend an hour re-figuring this out, so here it is…

Under certain conditions installing the ‘sqlite3-ruby’ gem on OSX with macgem fails with this error:

Building native extensions.  
This could take a while...
/bin/sh: line 1: 27196 Abort trap
/Library/Frameworks/MacRuby.framework/Versions/0.11/usr/bin/macruby extconf.rb
ERROR:  Error installing sqlite3-ruby:	ERROR: Failed to build gem native extension.

/Library/Frameworks/MacRuby.framework/Versions/0.11/usr/bin/macruby extconf.rb
checking for sqlite3.h... yes
checking for sqlite3_libversion_number() in -lsqlite3... no
sqlite3 is missing.
Try 'port install sqlite3 +universal'or 'yum install sqlite3-devel' 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
    ... etc ....

/Library/Frameworks/MacRuby.framework/Versions/0.11/usr/lib/ruby/Gems/1.9.2/
gems/sqlite3-ruby-1.3.2/ext/sqlite3/extconf.rb:20:
in `asplode:': sqlite3 is missing. Try 'port install sqlite3 +universal'or 'yum 
install sqlite3-devel' and check your shared library search path (the location 
where your sqlite3 shared library is located). (SystemExit) from 
/Library/Frameworks/MacRuby.framework/Versions/0.11/usr/lib/ruby/Gems/1.9.2/
gems/sqlite3-ruby-1.3.2/ext/sqlite3/extconf.rb:29:
in `<main>'\

The problem is that macports installs into /opt/local by default so even after doing ‘port install sqlite3 +universal’, you’ll get this error message. You need to specify the install prefix using this awkward command line:

sudo macgem install --version '= 1.3.2' sqlite3-ruby -- --with-sqlite3-dir=/opt/local

Version 1.3.2 is the one I’ve had luck with on MacRuby up to version 0.11.

Advertisements

NoSQL Bag of Links

Posted in database, nosql, ruby by steve on November 16, 2010