问题描述
我正在尝试在 Windows 上设置 Ruby on Rails.我正在使用看起来不错的 Flash Rails 发行版,但是 sqlite3 存在问题.我发现线程告诉我安装 1.2.3 版,安装得很好.我使用的是 ruby 1.9.0,每次尝试运行使用数据库的脚本(例如 rake db:create)时,都会收到错误消息找不到 sqlite3 的驱动程序".
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".
这显然是缺少 sqlite3.dll,但我的 %PATH% 中有 dll,我也尝试将其复制到运行脚本的目录中,即 sqlite3 ruby 代码所在的目录.
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.
有人有什么想法吗?如果可能的话,我希望所有 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.
澄清一下,我已经使用 gem install 来安装 ruby-sqlite3 gem - 它只是不起作用,因为它找不到 sqlite3.dll(即使它实际上存在于我的 %PATH% 目录中)
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: 进一步挖掘之后,问题出现了 ruby 不会加载 sqlite3_api.dll.我已经将它复制到我的文件系统中,我只是无法读取文件.同一目录中的其他 dll 库(例如 zlib.dll)工作正常!我尝试将 dll 安装到 system32 中,但也没有用.
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.
推荐答案
问题简单来说就是 sqlite3-ruby 1.2.3 与 ruby 1.9 不兼容.这是因为 ruby 1.9 不将 .dll 文件用于 c 库,而是使用 .so 文件.此外,由于 sqlite3_api.dll 是针对 msvcrt-ruby18.dll 编写的.这意味着它只支持 ruby 1.8.*.
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.*.
好消息是有一个胖二进制版本,将同时支持 ruby 1.8 和 ruby 1.9.卸载所有以前版本的 sqlite3-ruby,然后安装这个版本.(您可能需要在卸载后手动删除某些版本的 gem.)为了安装它使用
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
这篇关于Ruby 在 Windows 上找不到 sqlite3 驱动程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!