Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Trouble with sqlite3 ruby 2.0 on Windows

I'm a newbie to programming, with ruby/rails successfully installed on my (mac) home computer. I'm trying to get ruby 2.0.0p195 (and Rails) set up on Windows at work (Windows 7, 32bit) and I'm failing on the sqlite3 installation. I've been through most of the solutions/suggestions I can find on the web, but just can't get it to work - the frustrating thing is that it tells me it's installed, but it doesn't work: - I've tried the knapsack installation http://www.ruby-forum.com/topic/4413168 - If I try to install --with-opt-dir=c:/sqlite3 (or any of the many variations suggested) it gives a native extension error. - I've put the .dll file in Ruby/bin, which is also in my PATH - I have the devkit installed

The 'gem install sqlite3' command is successful, and if I do 'gem list', sqlite3 v1.3.7 x86-mingw32 appears in the list, but if I 'require sqlite3' in IRB I get:

LoadError: cannot load such file -- sqlite3/sqlite3_native

And the mkmf log says:

find_header: checking for sqlite3.h... -------------------- no

But I've confirmed the sqlite3.h file (and the sqlite3.c, sqlite3.o, and sqlite3.h files) is in my c:\sqlite3 directory, and as noted above, I've also tried installing '--with-opt-dir'.

So next I trace the error when I 'require' sqlite to a file '\kernel_require.rb' in ruby/lib, and it references to this:

if Gem::Specification.unresolved_deps.empty? then
  return gem_original_require(path)
end

I'm lost, and WAY out of my depth. At this point my only solution would be either to completely uninstall and start again, or to downgrade to ruby 1.9.x, but others seem to have sqlite3 and ruby 2.0 working so it's obviously (?) semi-stable. Help?

UPDATE: I've now tried downgrading to ruby 1.9.3, and apart from pik reverting to the most recent version of ruby every time I shut the command line, I can actually get the server to run etc. So it seems this issue is related specifically to ruby 2.0.

like image 608
grist Avatar asked Mar 09 '26 18:03

grist


1 Answers

I am encountering the same issue, except that I don't really think that it is related to Ruby 2, but to rails 4 instead.

I have managed to install the sqlite3 gem by downloading the source, dll and exec (dll and executables need to be added to PATH accessible) and installying the gem with the follwing process:

Download:

  • http://www.sqlite.org/2013/sqlite-amalgamation-3071700.zip
  • http://www.sqlite.org/2013/sqlite-dll-win32-x86-3071700.zip

Extract and put the files in a location on your C drive or wherever you want. Then copy sqlite.dll and sqlite.def to the Ruby/bin directory.

Then you go to the DevKit directory and run msys.bat, in which you issue the following command:

gem install sqlite3 --platform=ruby -- --with-sqlite3-dir=path-to-sqlite --with-sqlite3-include=path-to-sqlite 

This allowed me to install the gem successfully (using Ruby-2.0.0-p247 x86 and devkit). I validated through irb doing:

require 'sqlite3'
SQLite3::SQLITE_VERSION

I'm still trying to figure out this issue.

I get the same error message when I try to start the server or whenever I try to run the rails console.

I'd love to get this issue fixed...

like image 148
autronix Avatar answered Mar 11 '26 09:03

autronix



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!