Windows / Ruby / Rails安装 – 。无法加载这样的文件–sqlite3 / sqlite3_native windows

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

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

我已经尝试了几乎所有推荐的方式,包括这个: 如何在Windows上为Ruby安装sqlite3?

但我仍然收到相同的错误消息。 非常感谢您的帮助! 如果您对我有任何疑问,请与我们联系。

运行$ 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 ' from C:/Ruby21-x64/lib/ruby/gems/2.1.0/gems/sqlite3-1.3.9-x64-mingw32/lib/sqlite3.rb:2:in `' 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 `' 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 `' from C:/Sites/aynulhabib-habib-framework-aca42deddccd/bin/rails:8:in `require' from C:/Sites/aynulhabib-habib-framework-aca42deddccd/bin/rails:8:in `' from -e:1:in `load' from -e:1:in `' Process finished with exit code 1 

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

这在sqlite3-ruby邮件列表中提到了这里 。

幸运的是,您不必切换到ruby 2.0
经过无尽的尝试,这个问题有了解决方案……

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


脚步

  • gem uninstall sqlite3 --all

资源

  • 下载最新的sqlite3-ruby, https://github.com/sparklemotion/sqlite3-ruby
  • 解压缩包

建立

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

安装

  • 输入dir’pkg’
  • gem install --local sqlite3-xxx.gem (’xxx’是版本代码)

校验

  • irb
  • require 'sqlite3'

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

捆绑更新sqlite3

捆绑更新nokogiri

我希望我帮助过你;)

如果你从Sqlite下载链接中提取“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

这应该工作。

如果上述内容适合您,请阅读此链接以获取更多说明。