本机 Ruby 模块出现错误“找不到指定的模块。” 这不是真的

Hub*_*bro 6 ruby sqlite

我刚刚使用以下命令安装了适用于 Windows 的 Ruby gem“sqlite3”

>gem install sqlite3 --platform=ruby -- --with-sqlite3-include=c:/sqlite3/include --with-sqlite3-lib=c:/sqlite3/lib --with-sqlite3-dir=c:/sqlite3/bin
Run Code Online (Sandbox Code Playgroud)

它编译看起来很完美,但是当我尝试包含 gem 时,我得到:

irb(main):001:0> 需要“sqlite3”
LoadError:126:找不到指定的模块。- C:/Ruby200/lib/ruby/gems/2.0.0/gems/sqlite3-1.3.9/lib/sqlite3/sqlite3_native.so
        来自 C:/Ruby200/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
        来自 C:/Ruby200/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
        来自 C:/Ruby200/lib/ruby/gems/2.0.0/gems/sqlite3-1.3.9/lib/sqlite3.rb:6:in `rescue in '
        来自 C:/Ruby200/lib/ruby/gems/2.0.0/gems/sqlite3-1.3.9/lib/sqlite3.rb:2:in `'
        来自 C:/Ruby200/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:135:in `require'
        来自 C:/Ruby200/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:135:in `require 中的救援'
        来自 C:/Ruby200/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:144:in `require'
        来自(irb):1
        来自 C:/Ruby200/bin/irb:12:in `'

所以我检查了它为“sqlite3_native.so”提供的路径,你瞧,它就在那里!就像它应该的那样。那么鲁比为什么要对我撒谎呢?我怎样才能找出宝石不起作用的真正原因?

我手动构建 gem 的原因是预构建的 gem 带有过时的 SQLite3 版本

Hub*_*bro 1

基本上我在这个答案的“注意”部分找到了我的答案。

“sqlite3.dll”和“sqlite3.def”需要放置在PATH. 我将它们复制到“C:\Ruby200\bin”中,现在我可以require "sqlite3"成功了。但我必须说,这是一个来自 Ruby 的极其无用的错误消息的示例。

  • 我有和你完全相同的问题,除了将 .def 和 .dll 放在我的系统路径上的文件夹中并没有改变错误。 (2认同)