Ruby无法在Windows上找到sqlite3驱动程序

时间:2021-05-31 04:13:56

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".

我试图在Windows上设置Ruby on Rails。我正在使用看起来相当不错的Flash Rails发行版,但是sqlite3存在问题。我发现线程告诉我安装版本1.2.3,安装正常。我正在使用ruby 1.9.0,每次我尝试运行使用数据库的脚本(例如rake db:create)时,都会收到错误消息“找不到sqlite3的驱动程序”。

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.

这显然是一个缺少的sqlite3.dll,但我的%PATH%中有dll,我也尝试将其复制到我运行脚本的目录,即sqlite3 ruby​​代码所在的目录。

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%)

编辑:为了澄清,我已经使用gem install来安装ruby-sqlite3 gem - 它只是没有功能,因为它找不到sqlite3.dll(即使它实际上存在于我的%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.

编辑第2部分:在做了一些挖掘后,问题似乎是ruby不会加载sqlite3_api.dll。我已将其复制到我的文件系统上,我只是无法读取文件。同一目录中的其他dll库(例如zlib.dll)工作正常!我尝试将dll安装到system32中,但这也无效。

8 个解决方案

#1


7  

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.*.

简单问题就是sqlite3-ruby 1.2.3与ruby 1.9不兼容。这是因为ruby 1.9不使用.dll文件来代替它使用.so文件的c库。此外,因为sqlite3_api.dll是针对msvcrt-ruby18.dll编写的。这意味着它特别只支持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

好消息是有一个胖二进制版本将支持ruby 1.8和ruby 1.9。卸载所有以前版本的sqlite3-ruby,然后安装此版本。 (您可能必须在卸载后手动删除gem的某些版本。)以便安装它使用

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

for more information see this website

有关更多信息,请访问此网站

#2


3  

Try installing the sqlite3-ruby gem:

尝试安装sqlite3-ruby gem:

gem install sqlite3-ruby

#3


3  

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.

作为参考,有一个位于gem的lib目录中的sqlite3_api.dll文件。还需要在路径*问sqlite3.dll文件。它们是不同的文件,第一个是gem需要将Ruby连接到C代码,而第二个包含实际的Sqlite实现。

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).

最好从sqlite网站获取第二个文件并将其解压缩到Ruby \ bin目录(因为你不应该手动将DLL放入windows或windows \ system目录中)。

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

因此,需要参考“sqlite3_api.dll”:

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:

并且“sqlite3.dll”需要在路径上,可能在:

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.)

至于“找不到驱动程序”问题,我建议先尝试简单的事情,确保gems安装正确,最新,并且RUBYLIB和PATH环境变量设置得恰当。 (可能需要重新启动系统才能完全传播更改。)

#4


3  

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

重新链接下载sqlitedll-3_6_10.zip并解压缩到ruby / bin!

#5


1  

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.

尝试去sqlite.org下载页面并获取压缩的dll。然后把它放在你的c:\ windows \ system32文件夹中,这应该允许Ruby找到它。

#6


1  

Restart your machine after running install sqlite3-ruby

运行install sqlite3-ruby后重新启动计算机

#7


0  

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

澄清一下,您使用的是哪种宝石? sqlite-ruby或sqlite3-ruby?

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

他们是同一个项目的一部分,但不同的版本。关键是sqlite3似乎包含驱动程序代码。

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%

但我的%PATH%中有dll

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

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

第一个将尝试查找C:\ sqlite \ sqlite3.dll \ sqlite3.dll,AFAIK。

#8


0  

I use Ruby 1.8.7 (works with 1.9.1 too) OS is WindowsXP SP3

我使用Ruby 1.8.7(也适用于1.9.1)操作系统是WindowsXP SP3

  1. Go to http://www.sqlite.org/download.html and Download file sqlitedll-3_7_0_1.zip (265.19 KiB) and unzip then we will get sqlite3.dll

    转到http://www.sqlite.org/download.html并下载文件sqlitedll-3_7_0_1.zip(265.19 KiB)然后解压缩然后我们将获得sqlite3.dll

  2. Copy sqlite3.dll to your bin folder as C:\Ruby191\bin or C:\Ruby187\bin then it works

    将sqlite3.dll复制到您的bin文件夹,如C:\ Ruby191 \ bin或C:\ Ruby187 \ bin,然后它可以工作

#1


7  

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.*.

简单问题就是sqlite3-ruby 1.2.3与ruby 1.9不兼容。这是因为ruby 1.9不使用.dll文件来代替它使用.so文件的c库。此外,因为sqlite3_api.dll是针对msvcrt-ruby18.dll编写的。这意味着它特别只支持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

好消息是有一个胖二进制版本将支持ruby 1.8和ruby 1.9。卸载所有以前版本的sqlite3-ruby,然后安装此版本。 (您可能必须在卸载后手动删除gem的某些版本。)以便安装它使用

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

for more information see this website

有关更多信息,请访问此网站

#2


3  

Try installing the sqlite3-ruby gem:

尝试安装sqlite3-ruby gem:

gem install sqlite3-ruby

#3


3  

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.

作为参考,有一个位于gem的lib目录中的sqlite3_api.dll文件。还需要在路径*问sqlite3.dll文件。它们是不同的文件,第一个是gem需要将Ruby连接到C代码,而第二个包含实际的Sqlite实现。

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).

最好从sqlite网站获取第二个文件并将其解压缩到Ruby \ bin目录(因为你不应该手动将DLL放入windows或windows \ system目录中)。

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

因此,需要参考“sqlite3_api.dll”:

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:

并且“sqlite3.dll”需要在路径上,可能在:

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.)

至于“找不到驱动程序”问题,我建议先尝试简单的事情,确保gems安装正确,最新,并且RUBYLIB和PATH环境变量设置得恰当。 (可能需要重新启动系统才能完全传播更改。)

#4


3  

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

重新链接下载sqlitedll-3_6_10.zip并解压缩到ruby / bin!

#5


1  

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.

尝试去sqlite.org下载页面并获取压缩的dll。然后把它放在你的c:\ windows \ system32文件夹中,这应该允许Ruby找到它。

#6


1  

Restart your machine after running install sqlite3-ruby

运行install sqlite3-ruby后重新启动计算机

#7


0  

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

澄清一下,您使用的是哪种宝石? sqlite-ruby或sqlite3-ruby?

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

他们是同一个项目的一部分,但不同的版本。关键是sqlite3似乎包含驱动程序代码。

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%

但我的%PATH%中有dll

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

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

第一个将尝试查找C:\ sqlite \ sqlite3.dll \ sqlite3.dll,AFAIK。

#8


0  

I use Ruby 1.8.7 (works with 1.9.1 too) OS is WindowsXP SP3

我使用Ruby 1.8.7(也适用于1.9.1)操作系统是WindowsXP SP3

  1. Go to http://www.sqlite.org/download.html and Download file sqlitedll-3_7_0_1.zip (265.19 KiB) and unzip then we will get sqlite3.dll

    转到http://www.sqlite.org/download.html并下载文件sqlitedll-3_7_0_1.zip(265.19 KiB)然后解压缩然后我们将获得sqlite3.dll

  2. Copy sqlite3.dll to your bin folder as C:\Ruby191\bin or C:\Ruby187\bin then it works

    将sqlite3.dll复制到您的bin文件夹,如C:\ Ruby191 \ bin或C:\ Ruby187 \ bin,然后它可以工作