0

我已经按照 github 上的所有步骤和 Ruby on rails 安装的官方文档进行了操作。我已经为 sqlite3 安装了 gem。另外,我已将 sqlite 的 dll 和 def 文件以及 .exe 文件复制到 Ruby/bin 我然后创建了一个名为 myapp 的示例应用程序并尝试通过命令“rails server”启动服务器

它给出了以下错误:

F:/Ruby200/lib/ruby/gems/2.0.0/gems/sqlite3-1.3.7-x86-mingw32/lib/sqlite3.rb:6:i
n `require': cannot load such file -- sqlite3/sqlite3_native (LoadError)
        from F:/Ruby200/lib/ruby/gems/2.0.0/gems/sqlite3-1.3.7-x86-mingw32/lib/s
qlite3.rb:6:in `rescue in <top (required)>'
        from F:/Ruby200/lib/ruby/gems/2.0.0/gems/sqlite3-1.3.7-x86-mingw32/lib/s
qlite3.rb:2:in `<top (required)>'
        from F:/Ruby200/lib/ruby/gems/2.0.0/gems/bundler-1.3.4/lib/bundler/runti
me.rb:72:in `require'
        from F:/Ruby200/lib/ruby/gems/2.0.0/gems/bundler-1.3.4/lib/bundler/runti
me.rb:72:in `block (2 levels) in require'
        from F:/Ruby200/lib/ruby/gems/2.0.0/gems/bundler-1.3.4/lib/bundler/runti
me.rb:70:in `each'
        from F:/Ruby200/lib/ruby/gems/2.0.0/gems/bundler-1.3.4/lib/bundler/runti
me.rb:70:in `block in require'
        from F:/Ruby200/lib/ruby/gems/2.0.0/gems/bundler-1.3.4/lib/bundler/runti
me.rb:59:in `each'
        from F:/Ruby200/lib/ruby/gems/2.0.0/gems/bundler-1.3.4/lib/bundler/runti
me.rb:59:in `require'
        from F:/Ruby200/lib/ruby/gems/2.0.0/gems/bundler-1.3.4/lib/bundler.rb:13
2:in `require'
        from F:/myapp/config/application.rb:7:in `<top (required)>'
        from F:/Ruby200/lib/ruby/gems/2.0.0/gems/railties-3.2.13/lib/rails/comma
nds.rb:24:in `require'
        from F:/Ruby200/lib/ruby/gems/2.0.0/gems/railties-3.2.13/lib/rails/comma
nds.rb:24:in `<top (required)>'
        from script/rails:6:in `require'
        from script/rails:6:in `<main>'

这是“捆绑列表”命令的输出:

F:\myapp>bundle list
Gems included by the bund
  * actionmailer (3.2.13)
  * actionpack (3.2.13)
  * activemodel (3.2.13)
  * activerecord (3.2.13)
  * activeresource (3.2.1
  * activesupport (3.2.13
  * arel (3.0.2)
  * builder (3.0.4)
  * bundler (1.3.4)
  * coffee-rails (3.2.2)
  * coffee-script (2.2.0)
  * coffee-script-source
  * erubis (2.7.0)
  * execjs (1.4.0)
  * hike (1.2.1)
  * i18n (0.6.1)
  * journey (1.0.4)
  * jquery-rails (2.2.1)
  * json (1.7.7)
  * mail (2.5.3)
  * mime-types (1.22)
  * multi_json (1.7.2)
  * polyglot (0.3.3)
  * rack (1.4.5)
  * rack-cache (1.2)
  * rack-ssl (1.3.3)
  * rack-test (0.6.2)
  * rails (3.2.13)
  * railties (3.2.13)
  * rake (10.0.4)
  * rdoc (3.12.2)
  * sass (3.2.7)
  * sass-rails (3.2.6)
  * sprockets (2.2.2)
  * sqlite3 (1.3.7)
  * thor (0.18.1)
  * tilt (1.3.6)
  * treetop (1.4.12)
  * tzinfo (0.3.37)
  * uglifier (1.3.0)

请帮助我..我很想在 RoR 中创建 webapps,但我遇到了这些错误。提前致谢。

4

1 回答 1

0

从http://www.sqlite.org/download.html下载所需的可执行文件和 dll提取到您的 ruby​​ 的 bin (f:\Ruby200\bin)


如果您检查 sqlite3 的源代码:

# support multiple ruby version (fat binaries under windows)
begin
  RUBY_VERSION =~ /(\d+\.\d+)/
  require "sqlite3/#{$1}/sqlite3_native"
rescue LoadError
  require 'sqlite3/sqlite3_native'
end

您的应用程序在require 'sqlite3/sqlite3_native'上中断,您可以执行 irb 并尝试加载该文件,它应该会失败,修复它,并且您的应用程序应该可以毫无问题地运行。

确保在 %PATH% 上包含 ruby​​ 二进制文件的路径,这样当您执行require 'sqlite3/sqlite3_native'时,它实际上具有该文件的有效路径。

您也可以尝试添加 boot.rb 文件:

$LOAD_PATH.unshift('F:/Ruby200/bin')

所以应用程序,当您需要具有相对路径sqlite3/sqlite3_native的文件时,它实际上可以找到该文件。

一旦您能够加载该文件,它应该可以工作或利用分段错误(它的窗口:P)

于 2013-03-31T23:38:16.323 回答