4

First time I've tried installing Rails 4.0. On Windows 8 with Ruby 2.0 x64. Ran:

gem install rails --version 4.0.0.rc1 --no-ri --no-rdoc

Then I run:

rails new test_app
cd test_app
rails s

But the webpage at localhost:3000 reports the following error:

Specified 'sqlite3' for database adapter, but the gem is not loaded. Add gem 'sqlite3' to your Gemfile.

It's there in my Gemfile:

gem 'sqlite3'

I tried running bundle install several times and it doesn't even list it among all the other gems.

UPDATE: I've tried installing the sqlite3 gem in 2 different ways, both using the terminal that opens from the msys.bat file from the DevKit. The way the @szines below mentions gives me the following error:

$ gem install sqlite3 --platform=ruby -- --with-opt-dir=c:/sqlite-amalgamation-3071602
Temporarily enhancing PATH to include DevKit...
Building native extensions with: '--with-opt-dir=c:/sqlite-amalgamation-3071602'
This could take a while...
ERROR:  Error installing sqlite3:
        ERROR: Failed to build gem native extension.

    c:/Ruby200-x64/bin/ruby.exe extconf.rb --with-opt-dir=c:/sqlite-amalgamation-3071602
checking for sqlite3.h... yes
checking for sqlite3_libversion_number()... -lsqlite3
sqlite3 is missing. Install SQLite3 from http://www.sqlite.org/ first.
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers.  Check the mkmf.log file for more details.  You may
need configuration options.

Provided configuration options:
        --with-opt-dir
        --with-opt-include
        --without-opt-include=${opt-dir}/include
        --with-opt-lib
        --without-opt-lib=${opt-dir}/lib
        --with-make-prog
        --without-make-prog
        --srcdir=.
        --curdir
        --ruby=c:/Ruby200-x64/bin/ruby
        --with-sqlite3-dir
        --without-sqlite3-dir
        --with-sqlite3-include
        --without-sqlite3-include=${sqlite3-dir}/include
        --with-sqlite3-lib
        --without-sqlite3-lib=${sqlite3-dir}/
        --enable-local
        --disable-local
        --with-sqlite3lib
        --without-sqlite3lib


Gem files will remain installed in c:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/sqlite3-1.3.7 for inspection.
Results logged to c:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/sqlite3-1.3.7/ext/sqlite3/gem_make.out

The other way, I use the autoconf package from sqlite.org and I am able to compile and install the sqlite3 gem. However, when I try to open the Rails server I get the following error:

C:\Users\me\RubymineProjects\my_project>rails s
C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/sqlite3-1.3.7/lib/sqlite3.rb:6:in `require': cannot load such file -- sqlite3/sqlite3_native (LoadError)
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/sqlite3-1.3.7/lib/sqlite3.rb:6:in `rescue in <top (required)>'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/sqlite3-1.3.7/lib/sqlite3.rb:2:in `<top (required)>'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/bundler-1.3.5/lib/bundler/runtime.rb:72:in `require'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/bundler-1.3.5/lib/bundler/runtime.rb:72:in `block (2 levels) in require'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/bundler-1.3.5/lib/bundler/runtime.rb:70:in `each'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/bundler-1.3.5/lib/bundler/runtime.rb:70:in `block in require'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/bundler-1.3.5/lib/bundler/runtime.rb:59:in `each'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/bundler-1.3.5/lib/bundler/runtime.rb:59:in `require'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/bundler-1.3.5/lib/bundler.rb:132:in `require'
        from C:/Users/me/RubymineProjects/my_project/config/application.rb:7:in `<top (required)>'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/railties-4.0.0.rc1/lib/rails/commands.rb:78:in `require'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/railties-4.0.0.rc1/lib/rails/commands.rb:78:in `block in <top (required)>'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/railties-4.0.0.rc1/lib/rails/commands.rb:75:in `tap'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/railties-4.0.0.rc1/lib/rails/commands.rb:75:in `<top (required)>'
        from bin/rails:4:in `require'
        from bin/rails:4:in `<main>'
at.
  • 50,922
  • 104
  • 292
  • 461
  • Hi I recently ran across a very similar situation. That turned out to be a bug in Bundler, see: http://stackoverflow.com/questions/19653735/rails-4-fails-on-sqlite3 – will Nov 05 '13 at 05:45

6 Answers6

7

Pretty annoying, but I finally got it working. You basically have to do the following:

  1. Download sqlite files ready to be compiled by Luis Lavena (this is x64)
  2. Unarchive with 7-zip to maybe `c:\sqlite3
  3. Run msys.bat from within the DevKit folder you unarchived DevKit to
  4. Run gem install sqlite3 --platform=ruby -- --with-opt-dir=C:/sqlite3
at.
  • 50,922
  • 104
  • 292
  • 461
3

I am on a Mac OS X running Rails version 4.0.0 with Ruby 2.0, and the problem was that sqlite3 was not updated to a compatible version (and the warnings did not bother to say so).

Here is how I was able to fix the problem:

$ gem install sqlite3 --platform=ruby

This gave me an inkling that the most up-to-date version of sqlite3 was 1.3.7. Then I updated the sqlite3 gem in the gemfile accordingly. It was that simple.

La-comadreja
  • 5,627
  • 11
  • 36
  • 64
0

Download sqlite source files, and build sqlite gem with special parameters.

  • Download sqlite source code.
  • Create an sqlite folder on you PC. For example: c:/sqlite
  • Create three subfolder in this folder: c:/sqlite/include, c:/sqlite/lib, c:/sqlite/bin
  • Copy sources files:

c:/sqlite/bin => sqlite3.exe

c:/sqlite/include => sqlite3.h sqlite3ext.h

c:/sqlite/lib => libsqlite3.a sqlite3.la

  • Uninstall your previous sqlite gem with

gem uninstall sqlite3

  • Need compatible DevKit, for 64bit system x64 version.
  • Install compatible gem with the following command. (Don't forget the second empty two-dash.)

gem install sqlite3 --platform=ruby -- --with-opt-dir=c:/sqlite

Be careful, if you later run a bundle update command and you see that bundler install the 'official' sqlite gem, you have to uninstall 'old' version. You will get error message anyway if you have more version of sqlite.

Zoltan
  • 4,936
  • 1
  • 35
  • 40
  • Thank you @szines for your explanation. Unfortunately I still can't get the gem installed. I detailed the output in my original question. – at. May 14 '13 at 18:26
  • Have you created two subfolder in your c:/sqlite-amalgamation-3071602 folder? You should have c:/sqlite-amalgamation-3071602/lib and c:/sqlite-amalgamation-3071602/include and they contain two-two files as described above. I haven't wrote, but try to download binary version sqlite as well and copy in your ruby bin directory and in your windows directory to be certain that binary exist in your path. – Zoltan May 15 '13 at 09:53
  • Did this exactly as you suggested. Also tried adding the sqlite3.exe binary in a bin directory and in the c:\windows directory. I always get the same error: `sqlite3 is missing. Install SQLite3 from http://www.sqlite.org/ first. *** extconf.rb failed ***` – at. May 23 '13 at 05:58
  • I'm using Ruby 2.0.0 x64, is that what you used too? – at. May 23 '13 at 06:12
  • you're basically missing the `.a` files in the lib directory – at. May 23 '13 at 07:21
  • Yes, you are right. In the lib folder should be libsqlite3.a and libsqlite3.la... fixed my answer. – Zoltan May 23 '13 at 20:10
0

*This answer is for Ruby 2.0.0 x86, not x64.

I think I have it. The grail. The land of milk and honey. That box in Indiana Jones that the crazy lights shoot out of. Ice cream that doesn't melt in the sun.

After trying just about every answer on here, what finally did it for me (unless I'm hallucinating) was https://stackoverflow.com/a/16524605/765352 (the last comment in How do I install sqlite3 for Ruby on Windows?).

I was running Ruby 2.0.0 x86 on Windows 8, using a RailsInstaller version of Ruby.

Just to elaborate on his answer by providing the links:

  1. Go to http://www.sqlite.org (specifically http://sqlite.org/download.html) and download:

(I have no clue if those last two are needed. And, I'm not going back down the rabbit hole to check.)

  1. Unpack all those ZIPs to a directory of your choice. I used "sqlite-amalgamation-301700". (DIR).

  2. Get into your ruby shell, and type

    gem install sqlite3 --platform=ruby -- --with-sqlite3-dir=c:/sqlite-amalgamation-3071602 --with-sqlite3-include=c:/sqlite-amalgamation-3071602

You should see

C:\xx\>gem install sqlite3 --platform=ruby -- --with-sqlite3-dir=c:/sqlite-amalgamation-3071602 --with-sqlite3-include=c:/sqlite-amalgamation-3071602
Temporarily enhancing PATH to include DevKit...
Building native extensions with: '--with-sqlite3-dir=c:/sqlite-amalgamation-3071602 --with-sqlite3-include=c:/sqlite-amalgamation-3071602'
This could take a while...
Successfully installed sqlite3-1.3.7
Parsing documentation for sqlite3-1.3.7
unable to convert "\x90" from ASCII-8BIT to UTF-8 for lib/sqlite3/sqlite3_native.so, skipp
ing
Installing ri documentation for sqlite3-1.3.7
Done installing documentation for sqlite3 (3 sec).
1 gem installed

Booyah. Take that, auto-compiled nothing. And no thanks to SQLITE, which proved a heavyweight. And all thanks to Google, as always.

References:

  • this very thread;

  • the very guy who wrote https://stackoverflow.com/a/16524605/765352;

  • a bunch of threads talking about sqlite.org;

  • StackExchange, for not giving up on me;

  • me, for not giving up on StackExchange;

  • all the believers out there;

  • my producer and manager, who loves me (I love you Al).

Community
  • 1
  • 1
Jon
  • 310
  • 2
  • 10
  • This did not work for me. I did all these instructions perfectly except made the directories end with 3071700 instead of 3071602 like you had in the `gem install` command. – at. May 23 '13 at 05:51
  • I'm using Ruby 2.0.0 x64 on Windows 8. Is that what you used for the above too? – at. May 23 '13 at 06:12
  • you're basically missing the `.a` files in the lib directory, that's why it doesn't work with the above. – at. May 23 '13 at 07:21
  • The above does work. Just for Ruby 2 x86 on Windows 8, not Ruby 2 x64. I decided that it was enough running Rails beta on Ruby 2.0.0 that I wasn't going to mess around with a step up to 64 bit at the same time. I see you solved the x64 issue below. – Jon May 23 '13 at 11:58
0

Take a look at the resolution for this one:

In this case, there is a bug in a recent Bundler release. The pre-release Bundler fixed the problem.

Community
  • 1
  • 1
will
  • 4,799
  • 8
  • 54
  • 90
0

Thank you all guys, this is what worked for me for the installation of sqlite3:

Download sqlite-dll-win64-x64-3260000.zip , sqlite-tools-win32-x86-3260000.zip and sqlite-autoconf-3260000.tar.gz.

Place sqlite3.h and sqlite3ext.h in a folder called include

Place shell.c, sqlite3.c, sqlite3.def and sqlite3.dll in a folder called lib

gem install sqlite3 --platform=ruby -- --with-sqlite3-lib=c:/Devkit/sqlite3/lib --with-sqlite3-include=c:/Devkit/sqlite3/include
gem install data_mapper --platform=ruby -- --with-sqlite3-lib=c:/Devkit/sqlite3/lib --with-sqlite3-include=c:/Devkit/sqlite3/include
gem install dm-sqlite-adapter --platform=ruby -- --with-sqlite3-lib=c:/Devkit/sqlite3/lib --with-sqlite3-include=c:/Devkit/sqlite3/include
ToinoBiclas
  • 262
  • 4
  • 13