sqlite3-ruby gem: Failed to build gem native extension

53,608

Solution 1

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?

Solution 2

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

Solution 3

first from sqlite.org(http://www.sqlite.org/download.html)
download ->
Precompiled Binaries: sqlite-dll-win32-x86-3071700.zip
and Source Code: sqlite-autoconf-3071700.tar.gz
then extract as:

-include
    --sqlite3.h
    --sqlite3ext.h
-lib
    --shell.c
    --sqlite3.c
    --sqlite3.def
    --sqlite3.dll

last install gem like:

gem install sqlite3 --platform=ruby -- --with-sqlite3-include=path\to\include  
 --with-sqlite3-lib=path\to\lib --no-ri --no-rdoc

Good luck!

Solution 4

Is it possible that the newest version has not yet been ported to Win32 yet? Since this particular gem does have bindings to compiled code, it would require a platform-specific gem. If I force installation of version 1.2.3 rather than the current 1.2.4, the platform-specific version does install, but when I allow gem to try to install the current version, I get the generic 1.2.4 version (in the gems library folder, it lacks the -x86-mswin32 suffix that the other sqlite3-ruby folders have in their names.

Maybe someone else can answer how gem handles platform specific gems. Are separate gems uploaded for each platform and the gem software selects which one to pull down?

Solution 5

I had the same problem on Windows and I have installe MinGW http://sourceforge.net/projects/mingw/files/Automated%20MinGW%20Installer/MinGW%205.1.6/MinGW-5.1.6.exe/download and the problem has gone :-)

C:>gem install hpricot Successfully installed hpricot-0.8.2-x86-mswin32 1 gem installed Installing ri documentation for hpricot-0.8.2-x86-mswin32... Installing RDoc documentation for hpricot-0.8.2-x86-mswin32...

C:>gem install ruby-postgres Successfully installed ruby-postgres-0.7.1.2006.04.06-x86-mswin32 1 gem installed Installing ri documentation for ruby-postgres-0.7.1.2006.04.06-x86-mswin32... Installing RDoc documentation for ruby-postgres-0.7.1.2006.04.06-x86-mswin32...

Share:
53,608
Charles Roper
Author by

Charles Roper

Digital Services Manager at Field Studies Council.

Updated on July 09, 2022

Comments

  • Charles Roper
    Charles Roper almost 2 years

    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?

  • Nathan Fritz
    Nathan Fritz almost 16 years
    I suspect that the issue might be a bug in the gem and not with the gem system as a whole. If the gem doesn't specify that it is platform specific, the gem system probably assumes that it is a platform-agnostic gem and tries to install it.
  • mvexel
    mvexel over 13 years
    I (also) seemed to need libsqlite0-dev ( on top of libsqlite3-dev) to get the gem to install on Ubuntu 10.04.1 LTS. There's also a libsqlite3-ruby which I installed but I don't know if that made any difference