rails 3.0 on windows 7: problem with sqlite3

Yesterday I spent couple of hours fighting with Ruby 1.9.2 / Ruby on Rails 3.0 installation on Windows 7 Professional (64 bit). I always hit some kind of problem related to sqlite3 database (that is used by default in Ruby on Rails). There are number of hints, tutorials and forums on this topic on internet, but sometimes misleading. The cause of problem was version of the DLL file.

So next time, when you hit problem like this:

And you will see this error message:

/ruby/lib/ruby/gems/1.9.1/gems/sqlite3-1.3.3-x86-mingw32/lib/sqlite3.rb:6:in `require‘: no such file to load — sqlite3/sqlite3_native (LoadError)
        from C:/dev/ruby/lib/ruby/gems/1.9.1/gems/sqlite3-1.3.3-x86-mingw32/lib/sqlite3.rb:6:in `rescue in ‚

You can follow these instructions to get it fixed. This blog post is also for me so I don’t forgot this one 🙂

To install Ruby on Rails 3.0 on Windows 7 with sqlite3 from scratch, follow next steps:

  1. download and install Ruby using installer – rubyinstaller-1.9.2-p180.exe  from http://rubyinstaller.org/
  2. download sqlite3 DLL from http://www.sqlite.org/sqlitedll-3_7_3.zip and unzip into ruby/bin dir
    (= 2 files: sqlite3.def, sqlite3.dll)
  3. check version of ruby: ruby -v  (expected 1.9.2+)
  4. gem install rails
  5. check version of rails: rails -v  (expected 3.0+)
  6. to verify that your installation works properly, try to create a new rails app and test it:

    rails new foo
    cd foo
    bundle install
    rails generate scaffold Foo name:string email:string
    rake db:migrate
    rails s

This looks pretty obvious, but it was a few hours battle to get here. Even the Ruby on Rails 3 Tutorial book by Michael Hartl mentions problems with version of sqllite3 gem (1.2.5 vs. 1.3.1) that requires hacking of the auto-generated Gemfile.

IMPORTANT

The key to success here is to download the DLL exactly from here http://www.sqlite.org/sqlitedll-3_7_3.zip. Because the latest version of DLL from  http://sqlite.org/download.html does not work and you get into troubles, thinking the problem is in gem or wrong location of DLLs… It is not, latest version of this DLL simply does not work with this version of Ruby!
Advertisements

Zanechat Odpověď

Vyplňte detaily níže nebo klikněte na ikonu pro přihlášení:

WordPress.com Logo

Komentujete pomocí vašeho WordPress.com účtu. Odhlásit / Změnit )

Twitter picture

Komentujete pomocí vašeho Twitter účtu. Odhlásit / Změnit )

Facebook photo

Komentujete pomocí vašeho Facebook účtu. Odhlásit / Změnit )

Google+ photo

Komentujete pomocí vašeho Google+ účtu. Odhlásit / Změnit )

Připojování k %s