Windows/Ruby/Rails install --- .cannot load such file -- sqlite3/sqlite3_native windows
Asked Answered
C

4

5

Ruby 2.1.3p242 <2014-09-19 revision 47630> [x64-mingw32] Rails 4.2.0.beta2

I'm running windows 8 on a 64 bit system. I have been using c9 (cloud hosted ubuntu) but want to start using RubyMine IDE on my pc to make everything faster but it's posing some problems.

I've tried pretty much every recommended way including this one: How do I install sqlite3 for Ruby on Windows?

but I'm still getting the same error message. You help is much appreciated! Please let me know if you have any questions for me.

Full Error message when I run $rails s:

C:/Ruby21-x64/lib/ruby/gems/2.1.0/gems/activesupport-4.2.0.beta2/lib/active_support/dependencies.rb:248:in `require': cannot load such file -- sqlite3/sqlite3_native (LoadError)
    from C:/Ruby21-x64/lib/ruby/gems/2.1.0/gems/activesupport-4.2.0.beta2/lib/active_support/dependencies.rb:248:in `block in require'
    from C:/Ruby21-x64/lib/ruby/gems/2.1.0/gems/activesupport-4.2.0.beta2/lib/active_support/dependencies.rb:233:in `load_dependency'
    from C:/Ruby21-x64/lib/ruby/gems/2.1.0/gems/activesupport-4.2.0.beta2/lib/active_support/dependencies.rb:248:in `require'
    from C:/Ruby21-x64/lib/ruby/gems/2.1.0/gems/sqlite3-1.3.9-x64-mingw32/lib/sqlite3.rb:6:in `rescue in <top (required)>'
    from C:/Ruby21-x64/lib/ruby/gems/2.1.0/gems/sqlite3-1.3.9-x64-mingw32/lib/sqlite3.rb:2:in `<top (required)>'
    from C:/Ruby21-x64/lib/ruby/gems/2.1.0/gems/bundler-1.7.4/lib/bundler/runtime.rb:76:in `require'
    from C:/Ruby21-x64/lib/ruby/gems/2.1.0/gems/bundler-1.7.4/lib/bundler/runtime.rb:76:in `block (2 levels) in require'
    from C:/Ruby21-x64/lib/ruby/gems/2.1.0/gems/bundler-1.7.4/lib/bundler/runtime.rb:72:in `each'
    from C:/Ruby21-x64/lib/ruby/gems/2.1.0/gems/bundler-1.7.4/lib/bundler/runtime.rb:72:in `block in require'
    from C:/Ruby21-x64/lib/ruby/gems/2.1.0/gems/bundler-1.7.4/lib/bundler/runtime.rb:61:in `each'
    from C:/Ruby21-x64/lib/ruby/gems/2.1.0/gems/bundler-1.7.4/lib/bundler/runtime.rb:61:in `require'
    from C:/Ruby21-x64/lib/ruby/gems/2.1.0/gems/bundler-1.7.4/lib/bundler.rb:133:in `require'
    from C:/Sites/aynulhabib-habib-framework-aca42deddccd/config/application.rb:7:in `<top (required)>'
    from C:/Ruby21-x64/lib/ruby/gems/2.1.0/gems/railties-4.2.0.beta2/lib/rails/commands/commands_tasks.rb:78:in `require'
    from C:/Ruby21-x64/lib/ruby/gems/2.1.0/gems/railties-4.2.0.beta2/lib/rails/commands/commands_tasks.rb:78:in `block in server'
    from C:/Ruby21-x64/lib/ruby/gems/2.1.0/gems/railties-4.2.0.beta2/lib/rails/commands/commands_tasks.rb:75:in `tap'
    from C:/Ruby21-x64/lib/ruby/gems/2.1.0/gems/railties-4.2.0.beta2/lib/rails/commands/commands_tasks.rb:75:in `server'
    from C:/Ruby21-x64/lib/ruby/gems/2.1.0/gems/railties-4.2.0.beta2/lib/rails/commands/commands_tasks.rb:39:in `run_command!'
    from C:/Ruby21-x64/lib/ruby/gems/2.1.0/gems/railties-4.2.0.beta2/lib/rails/commands.rb:17:in `<top (required)>'
    from C:/Sites/aynulhabib-habib-framework-aca42deddccd/bin/rails:8:in `require'
    from C:/Sites/aynulhabib-habib-framework-aca42deddccd/bin/rails:8:in `<top (required)>'
    from -e:1:in `load'
    from -e:1:in `<main>'

Process finished with exit code 1
Cal answered 29/10, 2014 at 17:1 Comment(0)
P
4

The issue is that binary sqlite3 gem do not include pre-compiled versions for Ruby 2.1.3

This is mentioned in the sqlite3-ruby mailing list here.

Pusey answered 29/10, 2014 at 18:45 Comment(2)
ah got it, so I need to switch to ruby 2.0, thanks for your help!Cal
@AynulHabib FYI, gem sqlite3 version 1.3.10 was released last night and includes support for 2.1 :)Pusey
M
10

fortunately, you don't have to switch to ruby 2.0
there is a solution to this issue, after endless trying...

https://github.com/hwding/sqlite3-ruby-win


Steps

Pre

  • gem uninstall sqlite3 --all

Source

Build

  • run command-line in the extracted dir
  • make sure you have your C compiler installed and added to PATH
  • gem install bundler
  • bundle install
  • rake native gem
  • you'll find a dir named 'pkg' generated

Install

  • enter dir 'pkg'
  • gem install --local sqlite3-xxx.gem ('xxx' is version code)

Check

  • irb
  • require 'sqlite3'
Maryrosemarys answered 25/8, 2016 at 3:52 Comment(3)
This is what finally made it! Thanks! This shoud be the accepted answer.Chevaldefrise
unfortunately getting this : rake aborted! NoMethodError: undefined method `split' for nil:NilClass while executing rake native gemJudyjudye
It does not create 'pkg' directoryCommemoration
P
4

The issue is that binary sqlite3 gem do not include pre-compiled versions for Ruby 2.1.3

This is mentioned in the sqlite3-ruby mailing list here.

Pusey answered 29/10, 2014 at 18:45 Comment(2)
ah got it, so I need to switch to ruby 2.0, thanks for your help!Cal
@AynulHabib FYI, gem sqlite3 version 1.3.10 was released last night and includes support for 2.1 :)Pusey
L
1

In the folder of your project open terminal and execute:

bundle update sqlite3

bundle update nokogiri

I hope i have helped you ;)

EDIT:

  • i always recommend using linux/mac for ruby, because some gems may get problematic, because of compiling errors with c

  • always use bundle to manage your gems, it is much easier*, you can install it by:

    • gem install bundler

    • bundle install - will install all the gems in your Gemfile

    • the last bundler version is not compatible withe ruby bellow 2.3, so use gem install bundler -v 1.16.4

Lowpitched answered 21/10, 2017 at 19:29 Comment(0)
W
0

If you have extracted "exe"s and "dll"s from Sqlite download link to Ruby's bin folder and still have this problem. Try this:

bundle update

gem uninstall sqlite3

Given a choice between multiple versions of sqlite3, choose last option 'All versions'. Enter last number here

Select gem to uninstall:
1. sqlite3-1.3.13
2. sqlite3-1.3.13-x64-mingw32
3. All versions
>3 .
.
If you remove this gem, these dependencies will not be met.
Continue with Uninstall? [yN]
> y

gem install sqlite3 --platform=ruby

rails s

This should work.

Read through this link for more explanation if above works for you.

Winded answered 15/10, 2018 at 12:52 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.