tags:

views:

4243

answers:

7

I am trying to set up Ruby on Rails on windows. I am using the Flash Rails distribution that looks pretty good, but there is an issue with sqlite3. I found the threads telling me to install version 1.2.3, which installed fine. I'm using ruby 1.9.0, and every time I try and run a script (e.g. rake db:create) that uses the database I get an error message "no driver for sqlite3 found".

This apparently is a missing sqlite3.dll, but I have the dll in my %PATH%, and I have also tried copying it into the directory where I am running the script from, the directory where the sqlite3 ruby code lives.

Does anyone have any ideas? If possible I want all teh ruby stuff to be self contained so I can use it from a pen drive.

EDIT: To clarify, I already used gem install to install the ruby-sqlite3 gem - it is just non functional as it cannot find the sqlite3.dll (even though it is actually present in a directory on my %PATH%)

EDIT PART 2: After doing some more digging, the problem appears that ruby will not load the sqlite3_api.dll. I have copied it all over my filesystem, I just get a failure to read file. Other dll libraries in the same directory (e.g. zlib.dll) work fine! I tried installing the dlls into system32, and that did not work either.

+1  A: 

Try installing the sqlite3-ruby gem:

gem install sqlite3-ruby
Darin Dimitrov
I did try that (that's what I was talking about with the version 1.2.3 comment). Essentially gem install sqlite3-ruby does not work on windows, you have to do gem install --version 1.2.3 sqlite-rubywhich installed, but left me the problem I have described.
Greg Reynolds
+1  A: 

Try going to sqlite.org download page and get the zipped up dll. Then put that in your c:\windows\system32 folder, that should allow Ruby to find it.

Lolindrath
A: 

To clarify, which gem are you using? sqlite-ruby or sqlite3-ruby?

They're part of the same project, but different releases. The key is that sqlite3 appears to have driver code included.

I assume you're attempting to use the first, since it's giving me the same error. If so, try switching.


Also.. How literal do you mean by this?

but I have the dll in my %PATH%

  1. PATH=...;C:\sqlite\sqlite3.dll
  2. PATH=...;C:\sqlite

The first will attempt to find C:\sqlite\sqlite3.dll\sqlite3.dll, AFAIK.

Jonathan Lonowski
I'm using sqlite3-ruby. I think something very wrong has gone wrong with the package...
Greg Reynolds
I meant that the dll is in a directory (actually more than one as I have been copying it around in desperation!) that is on my path. It is in fact the sqlite3_api.dll that is not being found, according to the error message.
Greg Reynolds
+2  A: 

Something similar happened to me recently so I thought I'd update my answer.

For reference there's a sqlite3_api.dll file located in the gem's lib directory. Also the sqlite3.dll file needs to be reachable on the path. They are different files, the first is required by the gem to interface Ruby to C code, while the second contains the actual Sqlite implementation.

It's best to get the second file from the sqlite website and extract it to the Ruby\bin directory (as you shouldn't manually put DLL's into the windows or windows\system directories any more).

So for reference "sqlite3_api.dll" needs to be in:

Ruby\lib\ruby\gems\1.8\gems\sqlite3-ruby-1.2.3-x86-mswin32\lib

and "sqlite3.dll" needs to be on the path, possibly in:

Ruby\bin

As for the "driver not found" problem I would suggest trying the easy things first and making sure gems is installed correctly, up to date, and that the RUBYLIB and PATH environment variables are set appropriately. (System restart may be required to propagate the changes fully.)

Daemin
Mine is in C:\Documents and Settings\greynolds\Desktop\FlashRails_Ruby1.9-Win32-0.9.0.2\Flash Rails Ruby1.9\ruby\lib\ruby\gems\1.9.0\gems\sqlite3-ruby-1.2.3-x86-mswin32\libWhich is in my path
Greg Reynolds
Well in my installation the DLL is not on the path, but just loaded as required by the gem. Also could it be that it can't find the sqlite3 gem, as the driver it refers to is the gem package, not the DLL.
Daemin
I dug into the code, and the failure to load error occurs when the gem code executes "package require sqlite3_api"
Greg Reynolds
+6  A: 

The problem put simply is that sqlite3-ruby 1.2.3 is not compatible with ruby 1.9. This is caused because ruby 1.9 does not use .dll files for c libraries it uses .so files instead. Additionally, since sqlite3_api.dll is written against msvcrt-ruby18.dll. This means that it specifically only will support ruby 1.8.*.

The good news is that there is a fat binary version that will support both ruby 1.8 and ruby 1.9. Uninstalling all former versions of sqlite3-ruby and then installing this one. (You may have to manually delete some versions the gem after uninstalling.) in order to install it use

install sqlite3-ruby --source http://gems.rubyinstaller.org

for more information see this website

The source parameter is no longer required. The newer 1.2.5 version of the gem includes support for these binaries.
Luis Lavena
Did this, still getting the same error, any thoughts?
Paul
Paul, are you still unable to get this working? sqlite3-ruby has been out and working for many months and many users reported success. Would like to know if this is still an issue.
Luis Lavena
A: 

hi

iam having problem with sqlite3 each time i try to run my allpication i recive this message: ruby.exe: no such file to load--ubygems i download sqlite3 and put in ruby folders as well as extract sqlite3 file what elsao and how can i slove this problem

thanks

adl
Where you got your installed Ruby? Ruby installations from either RubyInstaller or old One-Click Installers contain RubyGems, which seems you're lacking in your installation.RUBYOPT in your environment could be set from a previous installation, please remove that variable and things should work again.Or try RubyInstaller
Luis Lavena
+2  A: 

Re this link Download sqlitedll-3_6_10.zip and extract into ruby/bin!

IanVaughan