Installing/Updating SQLite3 on Windows

Installing SQLite3 DLL

To install SQLite3 in windows you require not only the gem but a DLL files in your system PATH (or in your windows/system32 folder).

To obtain the DLL, go to: http://www.sqlite.org/download.html

I always believe that DLLs belong in the windows/system32 folder but as long as you put yours somewhere where your PATH environment variable points to, you should be fine.

Installing/Updating the SQLite3 Gem

Normally to install the gem you’d call gem install sqlite3-ruby and it would do everything automatically but if you try it (as of today) it will give you the following error:

C:\>gem install sqlite3-ruby
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
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

As not helpful as that error message is, it turns out that the new version of sqlite3-ruby doesn’t have a win32 version (which is needed for it to install/function correctly). So all you have to do is specify an older version of sqlite3.

To install a older version of a gem, run:

gem install --version 1.2.3 sqlite3-ruby

Now you’re all set to go!

Once sqlite3 is installed and you try to update the rest of your gems calling gem update, it will fail because (as of September 8th) sqlite3-ruby doesn’t have a win32 version of the 1.2.4 gem. To get around this, remove the sqlite3-ruby gem (gem uninstall sqlite3-ruby), then call gem update and then reinstall the gem by calling gem install –version 1.2.3 sqlite3-ruby.

SOURCE:

The most helpful site online that helped me figure this out was: http://www.ruby-forum.com/topic/164116

UPDATE:

I just tired updating the gems myself and had to uninstall sqlite3-ruby (it seems as of October 21st, 2008, they still haven’t fixed the issue!) and I copied the command of my own blog to find it doesn’t work. Not sure if it’s just firefox or wordpress but the problem is in the way the page is rendered, the “- – version” has a double dash (without the space) but the browser changes the html and makes it one dash. So I attempted to put it in a different format. So for those who had issues before, you can now copy the code above and just make sure that the version has a double dash in front of it.

10 Responses to “Installing/Updating SQLite3 on Windows”

  1. Marciano said:

    Sep 28, 08 at 8:33 PM

    Sorry your solution does not work 9/28.

    D:/Ruby/bin/ruby.exe extconf.rb install ûversion 1.2.3 sqlite3-ruby
    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 D:/Ruby/lib/ruby/gems/1.8/gems/sqlite3-ruby-1
    .2.4 for inspection.
    Results logged to D:/Ruby/lib/ruby/gems/1.8/gems/sqlite3-ruby-1.2.4/ext/sqlite3_
    api/gem_make.out

  2. andrew.kalek said:

    Sep 28, 08 at 9:02 PM

    It seems your still calling 1.2.4 (as you can see from your result). I’d recommend you re-type the command:
    gem install –version 1.2.3 sqlite3-ruby
    As copy and paste might be braking something.
    If you still have issues, let me know.

  3. andrew.kalek said:

    Sep 28, 08 at 9:06 PM

    Marciano, you might need to uninstall the gem first (by calling: gem uninstall sqlite3-ruby) then try to install again using the version flag.

  4. Branden said:

    Nov 25, 08 at 11:17 AM

    Just wanted to say thanks for your post. This saved me! 1.2.4 is still having some issues and I couldn’t figure out what the hell I did. Man they shouldn’t allow that in the repos when it’s breaking things. I updated to Rails 2.2 So I could try out some of the new features and sure enough sqlite 1.2.4 was pissed off at me. I’ve downgraded to 1.2.3 and everything is working fine. Thanks :)

  5. andrew.kalek said:

    Nov 25, 08 at 1:04 PM

    I’m glad I could help.

  6. Micke said:

    Jan 02, 09 at 12:52 PM

    Thanks mate!

    1.2.4 still doesn´t work…

  7. Jebac said:

    Mar 22, 09 at 1:40 AM

    Thanks mate! 1.2.3 and it worked :) I just wanted to play around with RoR almighty for the first time and ran into couple of needless frustrations. RoR community is advertising this as something beyond any realms of known universe, the ultimate truth and flawless technology. Yet in only first few steps to get it up and running there are so many errors and documentation mistakes it is unbelievable. Seems like working on Linux in 1999.

  8. Joachim said:

    May 07, 09 at 8:55 AM

    Thannk you very much, nice and clean explanation:)

  9. ERROR: While executing gem … (Zlib::BufError) in windows | Anlek's Blog said:

    May 21, 09 at 3:22 PM

    [...] First, based on dontrepeatyourself, I updated to the latested gem system (version 1.3.3). gem update –system Based on what I’ve read on the site, it fixed the issue for a lot of people (keep in mind this is an article from 2007) but it didn’t fix my issue. I continued looking for another solution, and I found a bunch of Window’s specific fixes that involved altering ruby code which I wasn’t going to attempt. Some article comments said to re-install ruby but who has time for that? Other posts (in the comments) said to download windows specific GZip ports but that also had no effect. I even installed a zliby gem hoping it would replace the Zlib but that still didn’t work. So I did what every windows user should do when the problem isn’t getting fixed, REBOOT!. After the reboot, gems updated without a problem (well except of the usual SQLite3 update error on windows [...]

  10. ElenaLisvato said:

    Aug 04, 09 at 2:53 PM

    It sounds like you’re creating problems yourself by trying to solve this issue instead of looking at why their is a problem in the first place.