The Windows version of Ruby on Rails does not ship with the Sqlite3 database, even though the database.yaml configuration file is preconfigured to use Sqlite.
This is a how to guide on how to install Sqlite3 on your Windows PC. This article assumes that you already have Ruby and Ruby on Rails installed on your PC.
First you will need to download two files from the Sqlite web site http://www.sqlite.org/download.html:
sqlite-3_5_9.zip (214.32 KiB)
A command-line program for accessing and modifing SQLite databases.
See the documentation for additional information.
sqlitedll-3_5_9.zip (213.17 KiB)
This is a DLL of the SQLite library without the TCL bindings.
The only external dependency is MSVCRT.DLL.
The first file is the Sqlite command line program used for modifing the Sqlite database. You may or may not use this.
The second file is the Windows DLL library file and Ruby uses this when Rails makes Sqlite database calls.
When both these ZIP files have been extracted you should have the following files:
- sqlite3.exe
- sqlite3.def
- sqlite3.dll
Copy these file to the bin directory of your Ruby installation, if you followed the default Ruby installation it will be located here:
C:\ruby\bin
Now that you have the Sqlite3 files installed you need to tell Ruby how to use them. To do this you need to download the Ruby bindings for Sqlite3.
Fortunately this is easy to do, using Ruby gems. Simply at the command prompt type the following command:
gem install sqlite3-ruby
You will now need to tell Gems which version you need as you will be presented with the following output:
Bulk updating Gem source index for: http://gems.rubyforge.org
Select which gem to install for your platform (i386-mswin32)
1. sqlite3-ruby 1.2.2 (mswin32)
2. sqlite3-ruby 1.2.2 (ruby)
3. sqlite3-ruby 1.2.1 (mswin32)
4. sqlite3-ruby 1.2.1 (ruby)
5. Skip this gem
6. Cancel installation
>_
Please select option 1, sqlite3-ruby 1.2.2 (mswin32). All being successful you will get some output like this:
Successfully installed sqlite3-ruby-1.2.2-mswin32
Installing ri documentation for sqlite3-ruby-1.2.2-mswin32...
Installing RDoc documentation for sqlite3-ruby-1.2.2-mswin32...
If you are using Rails 2+ you should be able to run the following rake tasks from your Rails application directory. For example say you created a Rails application located here: C:\MyApp you should be able to execute:
C:\MyApp>rake db:create
or
C:\MyApp>rake db:migrate
Hope this is useful.
I always installed it conveniently using the modified Gem by _why like this: gem install sqlite3-ruby –source=http://code.whytheluckystiff.net
See also: http://redhanded.hobix.com/cult/sqlite3Gem_whySSensibilitiesRepack.html
Just tried it again on a fresh system: Somehow it didn’t work for me this time, but I could swear it worked last time i tried it…
thx alot! This is an easy and great solution!
Thank you mate! I was tearing my hair out trying to get this to work on Windows. There is quite a lot of confusion on the internet about this topic, but your solution worked perfectly. Thanks
This did not work for me – instead what worked was:
gem install –version 1.2.3 sqlite3-ruby
as directed at: http://blog.muse.net.nz/2008/09/07/setup-rails-on-windows-to-use-sqlite3/
With forementioned cmd I got errors:
checking for fdatasync() in rt.lib… no checking for sqlite3.h… no
nmake
Microsoft (R) Program Maintenance Utility Version 1.50 Copyright (c) Microsoft Corp 1988-94. All rights reserved.
NMAKE : fatal error U1073: don’t know how to make ‘ruby.h’ Stop.
Just a Thank You for your unusually lucid instructions. They worked perfectly for me except that choice #1 on the menu isn’t the right one any more. For other newbs, however, this is no problem: just choose the item marked (mswin32).
Just a Thank You for your unusually lucid instructions. They worked perfectly for me except that choice #1 on the menu isn’t the right one any more. For other newbs, however, this is no problem: just choose the latest version that is marked (mswin32).
Same as Steve, and can’t find a fix online–this thread is the top hit for a search for the “checking for sqlite3.h… no” message. Anyone know what’s up?
Figured it out. This guy has it right:
http://samdelacruz.blogspot.com/2008/11/install-sqlite3-ruby-for-rails-on.html
The sqlite3 gem has to be installed with a –version argument. I used 1.2.3 as indicated in the above document, but others may want another version.
sqlite3-ruby version 1.2.4 is buggy and you can’t install it from a windows prompt. You need to type: “gem install sqlite3-ruby –version=1.2.3″. The most recent version that “works” with windows is 1.2.3. If you do “gem install sqlite3-ruby” you will get errors in windows.
I was pulling my hair out as none of the aformentioned gem installations worked… it seems you need two dashes for the version. Thats what worked for me at least.
gem install sqlite3-ruby –version=1.2.3
This helped greatly; you’d think the RoR guys would have caught this? Was quite confusing to have to figure out why sqlite3 gems wouldn’t install and furthermore, why would the sqlite3 libraries not be included?
Oh well.
Thanks a lot!!!!!
none of these commands works for me!
ERROR: while executing gem … Illformed requirement ["ersion=1.2.3"]
I’ve got the same error as Justin.
So i’ve used:
gem install sqlite3-ruby –version=1.2.3
And finally it worked for me.
Grtz, Richard
Aha, i see the problem. In the texteditor of this blog converts two dashes automatically into one dash. let try it again:
gem install sqlite3-ruby – -version=1.2.3 ^ type two dashes before “version”
Thank you; thank you; thank you!
It’s too bad there aren’t many more helpful win/ruby developers out there. This has been the most helpful post I’ve found on this topic.
You’ve saved my forehead from a great amount of further pounding.
Thanks a lot. You safed my day.
Join all the thanks above! It was pretty hard to find, though…
Once again this is direct proof that Google is your best friend when it comes to finding answers on the web. I would never have figured this out without the help on this page. thanks!
I tried I downloaded and unzipped the sqlite3 files to my
c:\windows\system32 (directory — 3 files) and then I tried gem install -v 1.2.3 sqlite3-ruby
Excellent way to discourage windows users who WANT to learn ruby on rails… hopefully others can find this information easier than I did.
thanks a lot…!!!
WOW! Finally, eh? I’ve been developing on my production box since my machine crashed christmas day, and couldn’t get this to work! Note, if anyone STILL couldn’t get it to work: If you copied one of the above lines and pasted into your Window, you might have seen a funny u character before version. That’s from copying htmp, somehow. Just backspace & delete BOTH the dashes, then retype them. (Or just copy the whole thing…). What a relief to NOT see the error messages LOL! Thanks again, everyone! Dirk PS. I used version=1.2.3
Yeah guys this bug has been there for about 9 months and every time I load ruby on a WIN32 machine, I always forget that I you need to install ‘gem install sqlite3-ruby –version=1.2.3′. Don’t forget the two dashes before version…
Also if you’re on windows… make sure you download microsoft visual studio C++ Express edition so that you can compile any gems that require you to compile from source. Otherwise you’ll get those nasty can’t compile native extensions errors!
That covers about 80% of the headache of developing on windows…
Thanks..very very good..
Thanks a lot for this post!
Thank you ! this worked for me.
Worked Perfectly! Very well done and easy to follow. Thanks to you I can move on in my newbie ruby learning.
Thank U RichardW! I couldn’t find any good solutions!
thank you!!!!!
Thank you so much!
I am using Windows vista with Rails 2.4.5 ruby 1.9.1 p234 and sqlite 3.6.20 and sqlite3-ruby version 1.2.5. The shipped gem version of sqlite3 (3.0.x) does not work very well with webRick.
[...] I followed tips from emson. [...]
Thank you so much for the instructions!
It’s not so simply to buy a pretty good custom essays, preferably if you are busy. I recommend you to define buy an essay and to be void from scruple that your work will be done by writing service
i got the exe,dll and def files and put them in ruby\bin folder. Since i dont have internet on the box i am trying to install this in, i manually got the sqlite3-ruby gem (from gemcutter) and tried installing it. It didnt work so i got the sqlite3-ruby-1.2.3-x86-mswin32 gem file but it still gives me the same error, failed to build native extension.
C:\>gem install sqlite3-ruby-1.2.3-x86-mingw32.gem Building native extensions. This could take a while… ERROR: Error installing sqlite3-ruby-1.2.3-x86-mingw32.gem: ERROR: Failed to build gem native extension.
C:/Ruby/bin/ruby.exe extconf.rb 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.3-x86-mingw32 for inspection. Results logged to C:/Ruby/lib/ruby/gems/1.8/gems/sqlite3-ruby-1.2.3-x86-mingw32/ ext/sqlite3_api/gem_make.out
Please help… am a total noob at this…
Social comments and analytics for this post…
This post was mentioned on Twitter by aniketzamwar: configring SQlite: http://bit.ly/qhgfX...
[...] should get the version number of Ruby on Rails which will be displayed in the command prompt. …emson… Installing Sqlite3 on Windows for RailsThe Windows version of Ruby on Rails does not ship with the Sqlite3 … gem install sqlite3-ruby. [...]
That helped a lot, thanks