0

I have followed all the steps on github and the official documentation of Ruby on rails installation. I have installed the gem for sqlite3. Also , I have copied the dll and def file and .exe file of sqlite to Ruby/bin I then created a sample app called myapp and tried to initiate the server by the command "rails server"

It gives the following errors:

F:/Ruby200/lib/ruby/gems/2.0.0/gems/sqlite3-1.3.7-x86-mingw32/lib/sqlite3.rb:6:i
n `require': cannot load such file -- sqlite3/sqlite3_native (LoadError)
        from F:/Ruby200/lib/ruby/gems/2.0.0/gems/sqlite3-1.3.7-x86-mingw32/lib/s
qlite3.rb:6:in `rescue in <top (required)>'
        from F:/Ruby200/lib/ruby/gems/2.0.0/gems/sqlite3-1.3.7-x86-mingw32/lib/s
qlite3.rb:2:in `<top (required)>'
        from F:/Ruby200/lib/ruby/gems/2.0.0/gems/bundler-1.3.4/lib/bundler/runti
me.rb:72:in `require'
        from F:/Ruby200/lib/ruby/gems/2.0.0/gems/bundler-1.3.4/lib/bundler/runti
me.rb:72:in `block (2 levels) in require'
        from F:/Ruby200/lib/ruby/gems/2.0.0/gems/bundler-1.3.4/lib/bundler/runti
me.rb:70:in `each'
        from F:/Ruby200/lib/ruby/gems/2.0.0/gems/bundler-1.3.4/lib/bundler/runti
me.rb:70:in `block in require'
        from F:/Ruby200/lib/ruby/gems/2.0.0/gems/bundler-1.3.4/lib/bundler/runti
me.rb:59:in `each'
        from F:/Ruby200/lib/ruby/gems/2.0.0/gems/bundler-1.3.4/lib/bundler/runti
me.rb:59:in `require'
        from F:/Ruby200/lib/ruby/gems/2.0.0/gems/bundler-1.3.4/lib/bundler.rb:13
2:in `require'
        from F:/myapp/config/application.rb:7:in `<top (required)>'
        from F:/Ruby200/lib/ruby/gems/2.0.0/gems/railties-3.2.13/lib/rails/comma
nds.rb:24:in `require'
        from F:/Ruby200/lib/ruby/gems/2.0.0/gems/railties-3.2.13/lib/rails/comma
nds.rb:24:in `<top (required)>'
        from script/rails:6:in `require'
        from script/rails:6:in `<main>'

This is the output of "bundle list" command:

F:\myapp>bundle list
Gems included by the bund
  * actionmailer (3.2.13)
  * actionpack (3.2.13)
  * activemodel (3.2.13)
  * activerecord (3.2.13)
  * activeresource (3.2.1
  * activesupport (3.2.13
  * arel (3.0.2)
  * builder (3.0.4)
  * bundler (1.3.4)
  * coffee-rails (3.2.2)
  * coffee-script (2.2.0)
  * coffee-script-source
  * erubis (2.7.0)
  * execjs (1.4.0)
  * hike (1.2.1)
  * i18n (0.6.1)
  * journey (1.0.4)
  * jquery-rails (2.2.1)
  * json (1.7.7)
  * mail (2.5.3)
  * mime-types (1.22)
  * multi_json (1.7.2)
  * polyglot (0.3.3)
  * rack (1.4.5)
  * rack-cache (1.2)
  * rack-ssl (1.3.3)
  * rack-test (0.6.2)
  * rails (3.2.13)
  * railties (3.2.13)
  * rake (10.0.4)
  * rdoc (3.12.2)
  * sass (3.2.7)
  * sass-rails (3.2.6)
  * sprockets (2.2.2)
  * sqlite3 (1.3.7)
  * thor (0.18.1)
  * tilt (1.3.6)
  * treetop (1.4.12)
  * tzinfo (0.3.37)
  * uglifier (1.3.0)

Kindly help me..I am desperate to create webapps in RoR but am stuck with these errors. Thanks in advance.

Marcelo De Polli
  • 28,123
  • 4
  • 37
  • 47
Andre
  • 3
  • 1
  • 2
  • You will have to download the DLL from [here](http://www.sqlite.org/download.html) and then add it to your `F:/Ruby200/bin`folder. Same issue [here](http://stackoverflow.com/questions/7604049/no-such-file-to-load-sqlite3-sqlite3-native), [here](http://stackoverflow.com/questions/5745322/require-no-such-file-to-load-sqlite3-sqlite3-native-loaderror) and [here](http://stackoverflow.com/questions/5800920/error-no-such-file-to-load-sqlite3-sqlite3-native-loaderror). – Luís Ramalho Mar 31 '13 at 20:31
  • I have already written above that I have extracted the executable and dll to Ruby/bin folder...still its not working...there are issues in bundler.rb and config.rb which I am not able to understand. Refer the cmd output above. I dont think its just related to sqlite3 – Andre Apr 01 '13 at 06:30

1 Answers1

0

download the required executable and the dll from http://www.sqlite.org/download.html extract to your ruby's bin (f:\Ruby200\bin)


If you check the source code for sqlite3:

# support multiple ruby version (fat binaries under windows)
begin
  RUBY_VERSION =~ /(\d+\.\d+)/
  require "sqlite3/#{$1}/sqlite3_native"
rescue LoadError
  require 'sqlite3/sqlite3_native'
end

your app breaks on the require 'sqlite3/sqlite3_native', you can execute irb and try to load that file, and it should fail, fix that, and your app should run without any problem.

make sure to include the path to ruby binaries on %PATH% so when you execute require 'sqlite3/sqlite3_native' it actually has a valid path to that file.

You can also try by adding on your boot.rb file:

$LOAD_PATH.unshift('F:/Ruby200/bin')

so the app, when you require the file with the relative path sqlite3/sqlite3_native it actually can find the file.

once you are able to load that file, it should either work or exploit with a segmentation fault (its windows :P)

rorra
  • 9,593
  • 3
  • 39
  • 61
  • I have already written above that I have extracted the executable and dll to Ruby/bin folder...still its not working...there are issues in bundler.rb and config.rb which I am not able to understand. Refer the cmd output above. I dont think its just related to sqlite3 – Andre Apr 01 '13 at 06:30
  • did you updated the %PATH% as well? I'm 100% sure its a problem with the dll, check the error message, it cannot be more clear: "`require': cannot load such file -- sqlite3/sqlite3_native (LoadError)", you can check the source code of sqlite3 as well, its the driver that cannot be loaded. – rorra Apr 01 '13 at 07:43
  • Thanks a lot..I added the LOAD_PATH statement to the boot.rb file but without the $ sign as it was giving the same sqlite3 errors. Now only 2 errors are displayed as follows:F:\myapp>bundle check The Gemfile's dependencies are satisfied F:\myapp>rails server F:/myapp/config/boot.rb:1:in `': uninitialized constant LOAD_PATH (NameError) from F:/Ruby200/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_requir e.rb:45:in `require' from F:/Ruby200/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_requir e.rb:45:in `require' from script/rails:5:in `
    '
    – Andre Apr 02 '13 at 17:52
  • MY bad, I see the "$" is part of the syntax for LOAD_PATH. I tried using $: but the sqlite3 errors persist :( – Andre Apr 02 '13 at 18:05
  • And to you have the file F:/Ruby200/bin/sqlite3/sqlite3_native.dll ? – rorra Apr 02 '13 at 20:32
  • So by adding F:/Ruby200/bin to your load path, when you **require "sqlite3/sqlite3_native"** it will load the library on the relative path, you need both files, sqlite3.exe and sqlite3.dll. Try to put those files under F:/Ruby200/bin and if that doesn't work also put them under F:/Ruby200/bin/sqlite3. – rorra Apr 02 '13 at 20:37
  • All my correct attempts to run sqlite with rails failed. So I finally decided to switch to postgresql...and it works totally fine. Thanks for all the help anyways :D – Andre Apr 04 '13 at 17:32