views:

729

answers:

5

I'm having issues installing the sqlite3-ruby gem on crunchbang linux. After googling the past few hours and following several people with the same problem, I still haven't gotten it to work.

Here is what I see after trying a 'sudo gem install sqlite3-ruby'

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

/usr/bin/ruby1.8 extconf.rb
checking for sqlite3.h... yes
checking for sqlite3_libversion_number() in -lsqlite3... yes
checking for rb_proc_arity()... no
checking for sqlite3_initialize()... no
sqlite3-ruby only supports sqlite3 versions 3.6.16+, please upgrade!
* 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.

Next I ran across this page; http://groups.google.com/group/sqlite3-ruby/browse_thread/thread/f22d098b561c48af/6e754f7b2fc3cd75?#6e754f7b2fc3cd75

I downloaded sqlite-amalgamation-3.7.0.1.tar.gz and issued the following commands:

tar zxvf sqlite-amalgamation-3.7.0.1.tar.gz
cd cd sqlite-3.7.0.1
mkdir $HOME/sqlite
./configure --prefix=$HOME/sqlite
make && make install
sudo gem install sqlite3-ruby -- --with-sqlite3-dir=$HOME/sqlite

However, I still get the exact same error. I've used 'sudo apt-get install sqlite3 libsqlite3-dev' but I still get the exact same error.

Any advice?

And as a small aside, how come when I use 'sudo apt-get install sqlite3', it grabs 3.5.9 instead of the 3.7.0.1 I manually downloaded?

+1  A: 

This is due to extconf.rb picking up your old 3.5.9 library when testing for functions before putting together the Makefile.

One solution to cut this short is to apt-get remove sqlite3 and retry

sudo gem install sqlite3-ruby -- --with-sqlite3-dir=$HOME/sqlite

This may save you from incompatibilities if you want to use sqlite3 command line binary.

Another solution is to copy your new ~/sqlite/lib/libsqlite3.a into the build directory of your gem (see gem env, something like gems/sqlite3-ruby-1.3.1/ext/sqlite3) and retry

sudo gem install sqlite3-ruby

The test should pick up your new library now and install fine.

Jarek
A: 

I had the exact same problem. Jarek's solution worked when I moved all of the files (not just libsqlite3.a) from ~/sqlite/lib to gems/sqlite3-ruby-1.3.1/ext/sqlite3.

Jonathan
A: 

Jonathan/Jarek - would either of you mind elaborating on this solution? I'm having the same issue but I can't decipher your suggested fix.

For the first suggested solution I tried the following in the terminal...

apt-get remove sqlite3

and

sudo apt-get remove sqlite3

But the result is " -bash: apt-get: command not found "

For the second solution, I'm unsure how to copy or move the files suggested. I'm guessing cp or mv is needed but that's as far as I can figure out.

Shawn
A: 

Install a lower version of sqlite3-ruby should resolve your problem:

sudo gem install sqlite3-ruby --version=1.2.5
Alain Beauvois