sqlite3-ruby: LoadError on Windows x64, Ruby 2.3

I tried to run the newly generated Rails app on a Windows x64 PC and it failed:

$ rails s
C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/sqlite3-1.3.11-x64-mingw32/lib/sqlite3.rb:6:in `require': cannot load such file -- sqlite3/sqlite3_native (LoadError)
        from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/sqlite3-1.3.11-x64-mingw32/lib/sqlite3.rb:6:in `rescue in <top (required)>'
        from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/sqlite3-1.3.11-x64-mingw32/lib/sqlite3.rb:2:in `<top (required)>'
        from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/bundler-1.11.2/lib/bundler/runtime.rb:77:in `require'
        from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/bundler-1.11.2/lib/bundler/runtime.rb:77:in `block (2 levels) in require'
        from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/bundler-1.11.2/lib/bundler/runtime.rb:72:in `each'
        from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/bundler-1.11.2/lib/bundler/runtime.rb:72:in `block in require'
        from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/bundler-1.11.2/lib/bundler/runtime.rb:61:in `each'
        from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/bundler-1.11.2/lib/bundler/runtime.rb:61:in `require'
        from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/bundler-1.11.2/lib/bundler.rb:99:in `require'
        from D:/Users/Serguei/Mes documents/projects/rails_draft/config/application.rb:16:in `<top (required)>'
        from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/railties-4.2.6/lib/rails/commands/commands_tasks.rb:78:in `require'
        from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/railties-4.2.6/lib/rails/commands/commands_tasks.rb:78:in `block in server'
        from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/railties-4.2.6/lib/rails/commands/commands_tasks.rb:75:in `tap'
        from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/railties-4.2.6/lib/rails/commands/commands_tasks.rb:75:in `server'
        from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/railties-4.2.6/lib/rails/commands/commands_tasks.rb:39:in `run_command!'
        from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/railties-4.2.6/lib/rails/commands.rb:17:in `<top (required)>'
        from bin/rails:4:in `require'
        from bin/rails:4:in `<main>

Environment:

  • Windows 7 x64
  • Ruby 2.3
  • Rails 4.2.6

To reproduce:

  • create a Rails app rails new rails_app -T
  • run bundle
  • run rails s

Any tips on how to solve that ?

Thank you.

About this issue

  • Original URL
  • State: closed
  • Created 11 years ago
  • Reactions: 9
  • Comments: 15 (3 by maintainers)

Commits related to this issue

Most upvoted comments

@ArieShout I had the same problem. Rebuilding from source as is did resolve the issue for me on Windows 7 64 bit without aforementioned commit. Here are the steps:

  1. Install DevKit
  2. Get autoconf version of sqlite3 sources from https://www.sqlite.org/download.html
  3. Start msys shell of DevKit (I have gcc from strawberry perl on PATH, this way I’m sure correct compiler is used)
  4. In unpacked location for your sqlite3 configure static version only to avoid keeping DLL on PATH ./configure --disable-shared
  5. Build and install it make install DESTDIR=/c/dev/ruby/tmp
  6. Remove all existing sqlite3 gems gem uninstall sqlite3 --all
  7. Build and install this gem gem install sqlite3 --platform=ruby -- --with-sqlite3-include=/c/dev/ruby/tmp/usr/local/include --with-sqlite3-lib=/c/dev/ruby/tmp/usr/local/lib

You may change path where you stage sqlite3 binaries.

Note that folder structure of final gem is different. It has no subfolders for various ruby versions.

P.S. This SO question is relevant. The only difference is not to build shared version of sqlite3. Although there might be an option to use static version while building gem.

Hello all, The solution is: Edit file sqlite3-x.x.x.gemspec, change s.require_paths=[“lib”] to s.require_paths=[“lib/sqlite3_native”]

Linux/UNIX: /usr/local/share/gem/specifications/

Windows: C:\Ruby…\lib\ruby\gems\x.x.x\specifications
I fixed it with my similar problem.

Regards,

@mlt I resolved the problem similar to your steps. This does work when you require sqlite3 in Ruby. However, when used in Rails, the bundler will install the native version, which doesn’t work. I have to run bundle update, uninstall the native version with gem uninstall, and then edit the sqlite3 entry in the Gemfile.lock to sqlite3 (1.3.11).