【问题标题】:Windows/Ruby/Rails install --- .cannot load such file -- sqlite3/sqlite3_native windowsWindows/Ruby/Rails install --- .cannot load such file -- sqlite3/sqlite3_native windows
【发布时间】:2014-12-25 12:26:50
【问题描述】:

Ruby 2.1.3p242 [x64-mingw32] Rails 4.2.0.beta2

我在 64 位系统上运行 Windows 8。我一直在使用 c9(云托管的 ubuntu),但想开始在我的电脑上使用 RubyMine IDE 以使一切更快,但它带来了一些问题。

我已经尝试了几乎所有推荐的方法,包括这个: How do I install sqlite3 for Ruby on Windows?

但我仍然收到相同的错误消息。非常感谢您的帮助!如果您对我有任何问题,请告诉我。

运行 $rails s 时的完整错误消息:

C:/Ruby21-x64/lib/ruby/gems/2.1.0/gems/activesupport-4.2.0.beta2/lib/active_support/dependencies.rb:248:in `require': cannot load such file -- sqlite3/sqlite3_native (LoadError)
    from C:/Ruby21-x64/lib/ruby/gems/2.1.0/gems/activesupport-4.2.0.beta2/lib/active_support/dependencies.rb:248:in `block in require'
    from C:/Ruby21-x64/lib/ruby/gems/2.1.0/gems/activesupport-4.2.0.beta2/lib/active_support/dependencies.rb:233:in `load_dependency'
    from C:/Ruby21-x64/lib/ruby/gems/2.1.0/gems/activesupport-4.2.0.beta2/lib/active_support/dependencies.rb:248:in `require'
    from C:/Ruby21-x64/lib/ruby/gems/2.1.0/gems/sqlite3-1.3.9-x64-mingw32/lib/sqlite3.rb:6:in `rescue in <top (required)>'
    from C:/Ruby21-x64/lib/ruby/gems/2.1.0/gems/sqlite3-1.3.9-x64-mingw32/lib/sqlite3.rb:2:in `<top (required)>'
    from C:/Ruby21-x64/lib/ruby/gems/2.1.0/gems/bundler-1.7.4/lib/bundler/runtime.rb:76:in `require'
    from C:/Ruby21-x64/lib/ruby/gems/2.1.0/gems/bundler-1.7.4/lib/bundler/runtime.rb:76:in `block (2 levels) in require'
    from C:/Ruby21-x64/lib/ruby/gems/2.1.0/gems/bundler-1.7.4/lib/bundler/runtime.rb:72:in `each'
    from C:/Ruby21-x64/lib/ruby/gems/2.1.0/gems/bundler-1.7.4/lib/bundler/runtime.rb:72:in `block in require'
    from C:/Ruby21-x64/lib/ruby/gems/2.1.0/gems/bundler-1.7.4/lib/bundler/runtime.rb:61:in `each'
    from C:/Ruby21-x64/lib/ruby/gems/2.1.0/gems/bundler-1.7.4/lib/bundler/runtime.rb:61:in `require'
    from C:/Ruby21-x64/lib/ruby/gems/2.1.0/gems/bundler-1.7.4/lib/bundler.rb:133:in `require'
    from C:/Sites/aynulhabib-habib-framework-aca42deddccd/config/application.rb:7:in `<top (required)>'
    from C:/Ruby21-x64/lib/ruby/gems/2.1.0/gems/railties-4.2.0.beta2/lib/rails/commands/commands_tasks.rb:78:in `require'
    from C:/Ruby21-x64/lib/ruby/gems/2.1.0/gems/railties-4.2.0.beta2/lib/rails/commands/commands_tasks.rb:78:in `block in server'
    from C:/Ruby21-x64/lib/ruby/gems/2.1.0/gems/railties-4.2.0.beta2/lib/rails/commands/commands_tasks.rb:75:in `tap'
    from C:/Ruby21-x64/lib/ruby/gems/2.1.0/gems/railties-4.2.0.beta2/lib/rails/commands/commands_tasks.rb:75:in `server'
    from C:/Ruby21-x64/lib/ruby/gems/2.1.0/gems/railties-4.2.0.beta2/lib/rails/commands/commands_tasks.rb:39:in `run_command!'
    from C:/Ruby21-x64/lib/ruby/gems/2.1.0/gems/railties-4.2.0.beta2/lib/rails/commands.rb:17:in `<top (required)>'
    from C:/Sites/aynulhabib-habib-framework-aca42deddccd/bin/rails:8:in `require'
    from C:/Sites/aynulhabib-habib-framework-aca42deddccd/bin/rails:8:in `<top (required)>'
    from -e:1:in `load'
    from -e:1:in `<main>'

Process finished with exit code 1

【问题讨论】:

    标签: ruby-on-rails ruby ruby-on-rails-3 windows-8 sqlite


    【解决方案1】:

    问题在于二进制 sqlite3 gem 不包含 Ruby 2.1.3 的预编译版本

    这在 sqlite3-ruby 邮件列表 here 中有所提及。

    【讨论】:

    • 嗯知道了,所以我需要切换到 ruby​​ 2.0,谢谢你的帮助!
    • @AynulHabib 仅供参考,gem sqlite3 版本 1.3.10 已于昨晚发布,包括对 2.1 的支持 :)
    【解决方案2】:

    幸运的是,您不必切换到 ruby​​ 2.0
    经过无数次尝试,这个问题有一个解决方案......

    https://github.com/hwding/sqlite3-ruby-win


    步骤

    • gem uninstall sqlite3 --all

    来源

    构建

    • 在提取的目录中运行命令行
    • 确保已安装 C 编译器并将其添加到 PATH
    • gem install bundler
    • bundle install
    • rake native gem
    • 您会发现生成了一个名为“pkg”的目录

    安装

    • 输入目录“pkg”
    • gem install --local sqlite3-xxx.gem(‘xxx’为版本号)

    检查

    • irb
    • require 'sqlite3'

    【讨论】:

    • 终于成功了!谢谢!这应该是公认的答案。
    • 不幸的是:rake 中止了! NoMethodError:在执行 rake native gem 时,nil:NilClass 的未定义方法`split'
    • 它不会创建 'pkg' 目录
    【解决方案3】:

    在你的项目文件夹中打开终端并执行:

    捆绑更新 sqlite3

    捆绑更新 nokogiri

    希望对你有所帮助;)

    编辑:

    • 我始终建议使用 linux/mac 进行 ruby​​,因为某些 gem 可能会因为 c 的编译错误而出现问题

    • 总是使用 bundle 来管理你的 gem,它更容易*, 您可以通过以下方式安装它:

      • gem install bundler

      • bundle install - 将在您的 Gemfile 中安装所有 gems

      • 最新的bundler版本与ruby bellow 2.3不兼容,所以使用gem install bundler -v 1.16.4

    【讨论】:

      【解决方案4】:

      如果你已经从Sqlite download link 解压“exe”和“dll”到 Ruby 的 bin 文件夹,但仍然有这个问题。试试这个:

      bundle update

      gem uninstall sqlite3

      如果要在 sqlite3 的多个版本之间进行选择,请选择最后一个选项“所有版本”。在此处输入最后一个数字

      选择要卸载的 gem:
      1. sqlite3-1.3.13
      2. sqlite3-1.3.13-x64-mingw32
      3.所有版本
      >3 .
      .
      如果您删除此 gem,这些依赖项将不会得到满足。
      继续卸载? [yN]
      > y

      gem install sqlite3 --platform=ruby

      rails s

      这应该可行。

      如果以上内容适合您,请阅读此link 以获得更多说明。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2016-06-28
        • 2016-02-08
        • 1970-01-01
        • 2016-10-13
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多