tags:

views:

24545

answers:

7

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?

+2  A: 

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?

Nathan Fritz
+22  A: 

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?

Charles Roper
+2  A: 

@charlesroper

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.

Nathan Fritz
+1  A: 

on windows it is impossible to run gem update(unless you have a development machine for ruby itself+dozens of other headers), is there no way of skipping sqlite and hpricot and have a decent update for all the gems ... ?

See the following for a (very hacky) way to skip incompatible gems:http://stackoverflow.com/questions/134581/gem-update-on-windows-is-it-broken
Charles Roper
+1  A: 

I also ran into this problem. It's worth knowing that the difference between 1.2.3 and 1.2.4 is not significant. Here are the 1.2.4. release notes:

Release Name: 1.2.4

Notes: This release only updates the generated C file to reflect the compatibility changes that were made to the SWIG file. Binary builds (e.g., Windows) are not affected, and need no update. In general, you will not need this update unless you are using a version of Ruby prior to 1.8.6. (source: 1.2.4. release notes)

Hope that helps others!

+5  A: 

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

Mercurious
A: 

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...

taonet