Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

sqlite3-ruby gem: Failed to build gem native extension

Tags:

windows

ruby

gem

Update: Check out this follow-up question: Gem Update on Windows - is it broken?


On Windows, when I do this:

gem install sqlite3-ruby

I get the following error:

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

c:/ruby/bin/ruby.exe extconf.rb install sqlite3-ruby --platform Win32
checking for fdatasync() in rt.lib... no
checking for sqlite3.h... no

nmake
'nmake' is not recognized as an internal or external command,
operable program or batch file.


Gem files will remain installed in c:/ruby/lib/ruby/gems/1.8/gems/sqlite3-ruby-1.2.4 for inspection.
Results logged to c:/ruby/lib/ruby/gems/1.8/gems/sqlite3-ruby-1.2.4/ext/sqlite3_api/gem_make.out

Same thing happens with the hpricot gem. I seem to remember these gems installed just fine on < 1.0 gems, but now I'm on 1.2.0, things have gone screwy.

I have also tried this:

gem install sqlite3-ruby --platform Win32

Needless to say, this doesn't work either (same error)

Does anyone know what is going on here and how to fix this?


Update: Check out this follow-up question: Gem Update on Windows - is it broken?

like image 264
Charles Roper Avatar asked Sep 04 '08 13:09

Charles Roper


2 Answers

As Nathan suggests, this does appear to be related to the fact that the latest versions of the sqlite3-ruby and hpricot gems don't appear to have Windows versions. Here's what to do when faced with this situation (note, the name of the gem is automatically wildcarded, so you can type just sql and get a list of all gems beginning with sql):

$ gem list --remote --all sqlite

*** REMOTE GEMS ***

sqlite (2.0.1, 2.0.0, 1.3.1, 1.3.0, 1.2.9.1, 1.2.0, 1.1.3, 1.1.2, 1.1.1, 1.1)
sqlite-ruby (2.2.3, 2.2.2, 2.2.1, 2.2.0, 2.1.0, 2.0.3, 2.0.2)
sqlite3-ruby (1.2.4, 1.2.3, 1.2.2, 1.2.1, 1.2.0, 1.1.0, 1.0.1, 1.0.0, 0.9.0, 0.6.0, 0.5.0)

Then you can choose the version you would like to install:

gem install sqlite3-ruby -v 1.2.3

To successfully install hpricot, I did this:

gem install hpricot -v 0.6

Annoyingly, doing a gem update tries to update the gems to their latest, broken-on-Windows, versions. When the update routine encounters an error, it ditches you out of the whole process. There's a (hacky) solution to this problem here.

So, is this issue a bug in gems? Should gems not automatically detect the platform and install the latest compatible version?

like image 105
Charles Roper Avatar answered Nov 13 '22 23:11

Charles Roper


I had the same problem on Ubuntu, this solved the problem for me:

http://newsgroups.derkeiler.com/Archive/Comp/comp.lang.ruby/2008-08/msg00339.html

like image 9
Mercurious Avatar answered Nov 14 '22 00:11

Mercurious