在 Windows 中, rails s 给出了 3 个不同的错误,我修复了一个并获得了更多错误 [英] In Windows, rails s gives 3 different errors, I fix one and get a bunch more

查看:26
本文介绍了在 Windows 中, rails s 给出了 3 个不同的错误,我修复了一个并获得了更多错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

按照朋友发给我的指南,我尝试了rails s.

我在运行 rails s

时遇到这些错误

首先我会展示ruby和rails的版本

C:\>ruby -v红宝石 2.2.2p95(2015-04-13 修订版 50295)[x64-mingw32]C:\>rails -v导轨 4.2.1C:\>

我运行 rails new qwerty ,运行良好

C:\rubyblah>rails new qwerty创建创建 README.rdoc创建 Rakefile创建 config.ru创建 .gitignore创建 Gemfile创建应用程序创建应用程序/资产/javascripts/application.js创建应用程序/资产/样式表/application.css创建应用程序/控制器/application_controller.rb创建 app/helpers/application_helper.rb创建 app/views/layouts/application.html.erb创建应用程序/资产/图像/.keep创建应用程序/邮件程序/.keep创建应用程序/模型/.keep创建应用程序/控制器/关注点/.keep创建应用程序/模型/关注点/.keep创建 bin创建 bin/bundle创建垃圾箱/导轨创建垃圾箱/耙子创建垃圾箱/设置创建配置创建配置/routes.rb创建配置/应用程序.rb创建配置/environment.rb创建配置/secrets.yml创建配置/环境创建配置/环境/development.rb创建配置/环境/production.rb创建配置/环境/test.rb创建配置/初始值设定项创建配置/初始化程序/assets.rb创建配置/初始化程序/backtrace_silencers.rb创建配置/初始化程序/cookies_serializer.rb创建配置/初始化程序/filter_parameter_logging.rb创建配置/初始化程序/inflections.rb创建配置/初始化程序/mime_types.rb创建 config/initializers/session_store.rb创建配置/初始化程序/wrap_parameters.rb创建配置/语言环境创建配置/语言环境/en.yml创建配置/boot.rb创建配置/数据库.yml创建数据库创建 db/seeds.rb创建库创建库/任务创建 lib/tasks/.keep创建库/资产创建 lib/assets/.keep创建日志创建日志/.keep创造公众创建 public/404.html创建 public/422.html创建 public/500.html创建 public/favicon.ico创建 public/robots.txt创建测试/夹具创建测试/夹具/.keep创建测试/控制器创建测试/控制器/.keep创建测试/邮件程序创建 test/mailers/.keep创建测试/模型创建测试/模型/.保持创建测试/助手创建测试/助手/.keep创建测试/集成创建测试/集成/.keep创建 test/test_helper.rb创建 tmp/缓存创建 tmp/缓存/资产创建供应商/资产/javascripts创建供应商/资产/javascripts/.keep创建供应商/资产/样式表创建供应商/资产/样式表/.keep运行捆绑安装从 https://rubygems.org/......... 获取 gem 元数据从 https://rubygems.org/获取版本元数据...从 https://rubygems.org/获取依赖元数据.解决依赖...使用耙子 10.4.2使用 i18n 0.7.0使用 json 1.8.2使用 minitest 5.6.1使用线程安全 0.3.5使用 tzinfo 1.2.2使用 activesupport 4.2.1使用构建器 3.2.2使用erubis 2.7.0使用 mini_portile 0.6.2使用 nokogiri 1.6.6.2使用 rails-deprecated_sanitizer 1.0.3使用 rails-dom-testing 1.0.6使用丝瓜络 2.0.2使用 rails-html-sanitizer 1.0.2使用动作视图 4.2.1使用机架 1.6.1使用机架测试 0.6.3使用动作包 4.2.1使用 globalid 0.3.5使用活动作业 4.2.1使用 MIME 类型 2.6.1使用邮件 2.6.3使用 actionmailer 4.2.1使用活动模型 4.2.1使用 arel 6.0.0使用 activerecord 4.2.1使用 debug_inspector 0.0.2使用 binding_of_caller 0.7.2使用捆绑器 1.9.9使用列化 0.9.0使用 byebug 5.0.0使用咖啡脚本源 1.9.1.1使用 execjs 2.5.2使用咖啡脚本 2.4.1使用雷神 0.19.1使用导轨 4.2.1使用咖啡轨 4.1.0使用 multi_json 1.11.0使用 jbuilder 2.2.16使用 jquery-rails 4.0.3使用链轮 3.1.0使用链轮导轨 2.3.1使用导轨 4.2.1使用 rdoc 4.2.0使用 sass 3.4.14使用倾斜 1.4.1使用 sass-rails 5.0.3使用 sdoc 0.4.1使用 sqlite3 1.3.10使用 turbolinks 2.5.3使用 tzinfo-data 1.2015.4使用 uglifier 2.7.1使用网络控制台 2.1.2捆绑完成!12 个 Gemfile 依赖项,现在安装了 54 个 gem.使用 `bundle show [gemname]` 来查看捆绑的 gem 的安装位置.

--

然后捆绑安装就可以了

C:\rubyblah>cd qwertyC:\rubyblah\qwerty> 捆绑安装使用耙子 10.4.2使用 i18n 0.7.0使用 json 1.8.2使用 minitest 5.6.1使用线程安全 0.3.5使用 tzinfo 1.2.2使用 activesupport 4.2.1使用构建器 3.2.2使用erubis 2.7.0使用 mini_portile 0.6.2使用 nokogiri 1.6.6.2使用 rails-deprecated_sanitizer 1.0.3使用 rails-dom-testing 1.0.6使用丝瓜络 2.0.2使用 rails-html-sanitizer 1.0.2使用动作视图 4.2.1使用机架 1.6.1使用机架测试 0.6.3使用动作包 4.2.1使用 globalid 0.3.5使用活动作业 4.2.1使用 MIME 类型 2.6.1使用邮件 2.6.3使用 actionmailer 4.2.1使用活动模型 4.2.1使用 arel 6.0.0使用 activerecord 4.2.1使用 debug_inspector 0.0.2使用 binding_of_caller 0.7.2使用列化 0.9.0使用 byebug 5.0.0使用咖啡脚本源 1.9.1.1使用 execjs 2.5.2使用咖啡脚本 2.4.1使用雷神 0.19.1使用导轨 4.2.1使用咖啡轨 4.1.0使用 multi_json 1.11.0使用 jbuilder 2.2.16使用 jquery-rails 4.0.3使用捆绑器 1.9.9使用链轮 3.1.0使用链轮导轨 2.3.1使用导轨 4.2.1使用 rdoc 4.2.0使用 sass 3.4.14使用倾斜 1.4.1使用 sass-rails 5.0.3使用 sdoc 0.4.1使用 sqlite3 1.3.10使用 turbolinks 2.5.3使用 tzinfo-data 1.2015.4使用 uglifier 2.7.1使用网络控制台 2.1.2捆绑完成!12 个 Gemfile 依赖项,现在安装了 54 个 gem.使用 `bundle show [gemname]` 来查看捆绑的 gem 的安装位置.

--

然后 rails s,我得到这些错误

C:\rubyblah\qwerty>rails sC:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/sqlite3-1.3.10-x64-mingw32/lib/sqlite3.rb:6:in `require': 无法加载此类文件 -- sqlite3/sqlite3_native (LoadError)来自 C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/sqlite3-1.3.10-x64-mingw32/lib/sqlite3.rb:6:in`在<top(必需)>中的救援'来自 C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/sqlite3-1.3.10-x64-mingw32/lib/sqlite3.rb:2:in `'来自 C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/bundler-1.9.9/lib/bundler/runtime.rb:76:在`需要'来自 C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/bundler-1.9.9/lib/bundler/runtime.rb:76:in ‘block (2 levels) in require’来自 C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/bundler-1.9.9/lib/bundler/runtime.rb:72:在`每个'来自 C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/bundler-1.9.9/lib/bundler/runtime.rb:72:in ‘block in require’来自 C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/bundler-1.9.9/lib/bundler/runtime.rb:61:在`每个'来自 C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/bundler-1.9.9/lib/bundler/runtime.rb:61:在`需要'来自 C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/bundler-1.9.9/lib/bundler.rb:134:在`要求'来自 C:/rubyblah/qwerty/config/application.rb:7:in `'来自 C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/railties-4.2.1/lib/rails/commands/commands_tasks.rb:78:在`要求'来自 C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/railties-4.2.1/lib/rails/commands/commands_tasks.rb:78:在服务器中的块"中来自 C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/railties-4.2.1/lib/rails/commands/commands_tasks.rb:75:in`tap'来自 C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/railties-4.2.1/lib/rails/commands/commands_tasks.rb:75:在服务器"中来自 C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/railties-4.2.1/lib/rails/commands/commands_tasks.rb:39:in `run_command!'来自 C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/railties-4.2.1/lib/rails/commands.rb:17:in `'来自 bin/rails:4:in `require'来自 bin/rails:4:in `<main>'C:\rubyblah\qwerty>

我发现这个关于第一个错误

无法加载此类文件 -- ruby​​ on rails 上的 sqlite3/sqlite3_native (LoadError)

所以我按照说明编辑了相应的gemspec文件

C:\>dir sql*.gemspec/s/bC:\Ruby22-x64\lib\ruby\gems\2.2.0\specifications\sqlite3-1.3.10-x64-mingw32.gems胸肌

我编辑那个 gemspec 文件,将 s.require_paths = ["lib"] 更改为 s.require_paths = ["lib/sqlite3_native"]

然后当我运行 rails s 时,我得到了一大堆新的错误

C:\rubyblah\qwerty>rails sC:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/nokogiri-1.6.6.2-x64-mingw32/lib/nokogiri.rb:29:in `require': 无法加载此类文件 -- nokogiri/nokogiri (LoadError)来自 C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/nokogiri-1.6.6.2-x64-mingw32/lib/nokogiri.rb:29:in`在<顶部(必需)>中救援'来自 C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/nokogiri-1.6.6.2-x64-mingw32/lib/nokogiri.rb:25:in `'来自 C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/loofah-2.0.2/lib/loofah.rb:3:在‘需要’来自 C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/loofah-2.0.2/lib/loofah.rb:3:in `'来自 C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/rails-html-sanitizer-1.0.2/lib/rails-html-sanitizer.rb:2:in`require'来自 C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/rails-html-sanitizer-1.0.2/lib/rails-html-sanitizer.rb:2:in `<top (required)>'来自 C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/actionview-4.2.1/lib/action_查看/helpers/sanitize_helper.rb:3:in`require'来自 C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/actionview-4.2.1/lib/action_查看/helpers/sanitize_helper.rb:3:in `'来自 C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/actionview-4.2.1/lib/action_查看/helpers/text_helper.rb:32:in `'来自 C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/actionview-4.2.1/lib/action_查看/helpers/text_helper.rb:29:in `<module:Helpers>'来自 C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/actionview-4.2.1/lib/action_view/helpers/text_helper.rb:6:in `<module:ActionView>'来自 C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/actionview-4.2.1/lib/action_view/helpers/text_helper.rb:4:in `'来自 C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/actionview-4.2.1/lib/action_查看/helpers/form_tag_helper.rb:18:in `<module:FormTagHelper>'来自 C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/actionview-4.2.1/lib/action_查看/helpers/form_tag_helper.rb:14:in `<module:Helpers>'来自 C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/actionview-4.2.1/lib/action_view/helpers/form_tag_helper.rb:8:in `<module:ActionView>'来自 C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/actionview-4.2.1/lib/action_view/helpers/form_tag_helper.rb:6:in `'来自 C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/actionview-4.2.1/lib/action_查看/helpers/form_helper.rb:4:in`require'来自 C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/actionview-4.2.1/lib/action_view/helpers/form_helper.rb:4:in `'来自 C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/actionview-4.2.1/lib/action_view/helpers.rb:50:in `'来自 C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/actionview-4.2.1/lib/action_view/helpers.rb:4:in `'来自 C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/actionview-4.2.1/lib/action_view/helpers.rb:3:in `'来自 C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/sprockets-rails-2.3.1/lib/spRockets/rails/legacy_asset_tag_helper.rb:7:in `<module:LegacyAssetTagHelper>'来自 C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/sprockets-rails-2.3.1/lib/spRockets/rails/legacy_asset_tag_helper.rb:6:in `<module:Rails>'来自 C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/sprockets-rails-2.3.1/lib/spRockets/rails/legacy_asset_tag_helper.rb:4:in `<module:Sprockets>'来自 C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/sprockets-rails-2.3.1/lib/spRockets/rails/legacy_asset_tag_helper.rb:3:in `<top (required)>'来自 C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/sprockets-rails-2.3.1/lib/spRockets/rails/helper.rb:54:in `require'来自 C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/sprockets-rails-2.3.1/lib/spRockets/rails/helper.rb:54:in `<module:Helper>'来自 C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/sprockets-rails-2.3.1/lib/spRockets/rails/helper.rb:7:in `<module:Rails>'来自 C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/sprockets-rails-2.3.1/lib/spRockets/rails/helper.rb:6:in `<module:Sprockets>'来自 C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/sprockets-rails-2.3.1/lib/spRockets/rails/helper.rb:5:in `<top (required)>'来自 C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/sprockets-rails-2.3.1/lib/sp火箭/railtie.rb:6:在`要求'来自 C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/sprockets-rails-2.3.1/lib/spRockets/railtie.rb:6:in `'来自 C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/sass-rails-5.0.3/lib/sass/rails/railtie.rb:3:在`要求'来自 C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/sass-rails-5.0.3/lib/sass/rails/railtie.rb:3:in `'来自 C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/sass-rails-5.0.3/lib/sass/rails.rb:11:在`需要'来自 C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/sass-rails-5.0.3/lib/sass/rails.rb:11:in `'来自 C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/sass-rails-5.0.3/lib/sass-rails.rb:1:在`需要'来自 C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/sass-rails-5.0.3/lib/sass-rails.rb:1:in `'来自 C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/bundler-1.9.9/lib/bundler/runtime.rb:76:在`需要'来自 C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/bundler-1.9.9/lib/bundler/runtime.rb:76:in ‘block (2 levels) in require’来自 C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/bundler-1.9.9/lib/bundler/runtime.rb:72:在`每个'来自 C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/bundler-1.9.9/lib/bundler/runtime.rb:72:in ‘block in require’来自 C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/bundler-1.9.9/lib/bundler/runtime.rb:61:在`每个'来自 C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/bundler-1.9.9/lib/bundler/runtime.rb:61:在`需要'来自 C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/bundler-1.9.9/lib/bundler.rb:134:在`要求'来自 C:/rubyblah/qwerty/config/application.rb:7:in `'来自 C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/railties-4.2.1/lib/rails/commands/commands_tasks.rb:78:在`要求'来自 C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/railties-4.2.1/lib/rails/commands/commands_tasks.rb:78:在服务器中的块"中来自 C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/railties-4.2.1/lib/rails/commands/commands_tasks.rb:75:in`tap'来自 C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/railties-4.2.1/lib/rails/commands/commands_tasks.rb:75:在服务器"中来自 C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/railties-4.2.1/lib/rails/commands/commands_tasks.rb:39:in `run_command!'来自 C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/railties-4.2.1/lib/rails/commands.rb:17:in `'来自 bin/rails:4:in `require'来自 bin/rails:4:in `<main>'C:\rubyblah\qwerty>

解决方案

一个选项是将 ruby​​ 降级到一个稳定/适用于 Windows 的版本.另一种选择是安装 linux VM 并在那里安装 Ruby.

您需要安装在 Windows 上稳定的 Ruby 版本.

不是最新版本的 Ruby.在撰写本文时,最新版本是 2.2.2,在 Windows 上不稳定.

即使您使用的是 64 位机器,Windows 的稳定 Ruby 也是 32 位.

你想要 Ruby 2.1.X,例如Ruby 2.1.6(最新的 2.1.x 很好,2.1.6)而且你想要 32 位版本

http://dl.bintray.com/oneclick/rubyinstaller/rubyinstaller-2.1.6.exe

这里提到了 http://rubyinstaller.org/downloads/ "我们建议您使用 Ruby 2.1.X 安装程序.这些提供了一种稳定的语言和大量兼容和更新的包 (gems).

然而,并不是所有的包(gems)都得到维护.某些较旧的软件包可能与较新版本的 Ruby 和 RubyInstaller 不兼容.

Ruby 的 64 位版本在 Windows 领域相对较新,并且并非所有软件包都已更新以与其兼容.要使用这个版本,你需要一些关于编译器和解决依赖问题的知识,如果你只是想玩这个语言,这可能太复杂了."

注意该说明

因此删除您现有的任何 Ruby.

要删除 Ruby,请转到开始菜单..Ruby..,然后单击卸载".

那也应该卸载 Rails.

并删除任何开发包.devkit 可执行文件通过提取安装到您指定的文件夹中,因此只需 rmdir/remove 该文件夹.

现在安装稳定的 ruby​​.. 2.1.6 32bit安装 rails 和 devkit

安装 rails 的命令

gem 安装导轨

要安装 devkit,请确保您拥有正确的

例如

http://rubyinstaller.org/downloads/

哪个开发工具包?....Ruby 1.8.6 到 1.9.3:tdm-32-4.5.2Ruby 2.0.0 及以上(32 位):mingw64-32-4.7.2Ruby 2.0.0 及以上 x64(64 位):mingw64-64-4.7.2

所以你想要

Ruby 2.0.0 及以上(32 位):mingw64-32-4.7.2

查看可用的开发包

开发工具包

用于 Ruby 1.8.7 和 1.9.3:

DevKit-tdm-32-4.5.2-20111229-1559-sfx.exe
用于 Ruby 2.0 及更高版本(仅限 32 位版本):

DevKit-mingw64-32-4.7.2-20130224-1151-sfx.exe
用于 Ruby 2.0 及更高版本(仅限 x64 - 64 位)

DevKit-mingw64-64-4.7.2-20130224-1432-sfx.exe

你想要

DevKit-tdm-32-4.5.2-20111229-1559-sfx.exe
用于 Ruby 2.0 及更高版本(仅限 32 位版本):

http://dl.bintray.com/oneclick/rubyinstaller/DevKit-mingw64-32-4.7.2-20130224-1151-sfx.exe

按照此处的说明安装 devkit https://github.com/oneclick/rubyinstaller/wiki/Development-Kit

所以说你把它放在 c:\devkit

c:\devkit>ruby dk.rb 初始化

c:\devkit>ruby dk.rb 安装

你可以运行这个命令,虽然我认为没有必要c:\sdfsd>gem 安装 json --platform=ruby

所以现在你已经安装了 ruby​​ 和 rails 以及 devkit

rails new <项目名称>

cd <项目名称>

捆绑安装

rails

http://localhost:3000(在浏览器中)

上面写着欢迎登机"

following a guide a friend sent me, I tried rails s.

I am getting these errors when running rails s

First i'll show the version of ruby and rails

C:\>ruby -v
ruby 2.2.2p95 (2015-04-13 revision 50295) [x64-mingw32]

C:\>rails -v
Rails 4.2.1

C:\>

and I run rails new qwerty that goes fine

C:\rubyblah>rails new qwerty
      create
      create  README.rdoc
      create  Rakefile
      create  config.ru
      create  .gitignore
      create  Gemfile
      create  app
      create  app/assets/javascripts/application.js
      create  app/assets/stylesheets/application.css
      create  app/controllers/application_controller.rb
      create  app/helpers/application_helper.rb
      create  app/views/layouts/application.html.erb
      create  app/assets/images/.keep
      create  app/mailers/.keep
      create  app/models/.keep
      create  app/controllers/concerns/.keep
      create  app/models/concerns/.keep
      create  bin
      create  bin/bundle
      create  bin/rails
      create  bin/rake
      create  bin/setup
      create  config
      create  config/routes.rb
      create  config/application.rb
      create  config/environment.rb
      create  config/secrets.yml
      create  config/environments
      create  config/environments/development.rb
      create  config/environments/production.rb
      create  config/environments/test.rb
      create  config/initializers
      create  config/initializers/assets.rb
      create  config/initializers/backtrace_silencers.rb
      create  config/initializers/cookies_serializer.rb
      create  config/initializers/filter_parameter_logging.rb
      create  config/initializers/inflections.rb
      create  config/initializers/mime_types.rb
      create  config/initializers/session_store.rb
      create  config/initializers/wrap_parameters.rb
      create  config/locales
      create  config/locales/en.yml
      create  config/boot.rb
      create  config/database.yml
      create  db
      create  db/seeds.rb
      create  lib
      create  lib/tasks
      create  lib/tasks/.keep
      create  lib/assets
      create  lib/assets/.keep
      create  log
      create  log/.keep
      create  public
      create  public/404.html
      create  public/422.html
      create  public/500.html
      create  public/favicon.ico
      create  public/robots.txt
      create  test/fixtures
      create  test/fixtures/.keep
      create  test/controllers
      create  test/controllers/.keep
      create  test/mailers
      create  test/mailers/.keep
      create  test/models
      create  test/models/.keep
      create  test/helpers
      create  test/helpers/.keep
      create  test/integration
      create  test/integration/.keep
      create  test/test_helper.rb
      create  tmp/cache
      create  tmp/cache/assets
      create  vendor/assets/javascripts
      create  vendor/assets/javascripts/.keep
      create  vendor/assets/stylesheets
      create  vendor/assets/stylesheets/.keep
         run  bundle install
Fetching gem metadata from https://rubygems.org/............
Fetching version metadata from https://rubygems.org/...
Fetching dependency metadata from https://rubygems.org/..
Resolving dependencies...
Using rake 10.4.2
Using i18n 0.7.0
Using json 1.8.2
Using minitest 5.6.1
Using thread_safe 0.3.5
Using tzinfo 1.2.2
Using activesupport 4.2.1
Using builder 3.2.2
Using erubis 2.7.0
Using mini_portile 0.6.2
Using nokogiri 1.6.6.2
Using rails-deprecated_sanitizer 1.0.3
Using rails-dom-testing 1.0.6
Using loofah 2.0.2
Using rails-html-sanitizer 1.0.2
Using actionview 4.2.1
Using rack 1.6.1
Using rack-test 0.6.3
Using actionpack 4.2.1
Using globalid 0.3.5
Using activejob 4.2.1
Using mime-types 2.6.1
Using mail 2.6.3
Using actionmailer 4.2.1
Using activemodel 4.2.1
Using arel 6.0.0
Using activerecord 4.2.1
Using debug_inspector 0.0.2
Using binding_of_caller 0.7.2
Using bundler 1.9.9
Using columnize 0.9.0
Using byebug 5.0.0
Using coffee-script-source 1.9.1.1
Using execjs 2.5.2
Using coffee-script 2.4.1
Using thor 0.19.1
Using railties 4.2.1
Using coffee-rails 4.1.0
Using multi_json 1.11.0
Using jbuilder 2.2.16
Using jquery-rails 4.0.3
Using sprockets 3.1.0
Using sprockets-rails 2.3.1
Using rails 4.2.1
Using rdoc 4.2.0
Using sass 3.4.14
Using tilt 1.4.1
Using sass-rails 5.0.3
Using sdoc 0.4.1
Using sqlite3 1.3.10
Using turbolinks 2.5.3
Using tzinfo-data 1.2015.4
Using uglifier 2.7.1
Using web-console 2.1.2
Bundle complete! 12 Gemfile dependencies, 54 gems now installed.
Use `bundle show [gemname]` to see where a bundled gem is installed.

--

then bundle install goes fine

C:\rubyblah>cd qwerty

C:\rubyblah\qwerty>bundle install
Using rake 10.4.2
Using i18n 0.7.0
Using json 1.8.2
Using minitest 5.6.1
Using thread_safe 0.3.5
Using tzinfo 1.2.2
Using activesupport 4.2.1
Using builder 3.2.2
Using erubis 2.7.0
Using mini_portile 0.6.2
Using nokogiri 1.6.6.2
Using rails-deprecated_sanitizer 1.0.3
Using rails-dom-testing 1.0.6
Using loofah 2.0.2
Using rails-html-sanitizer 1.0.2
Using actionview 4.2.1
Using rack 1.6.1
Using rack-test 0.6.3
Using actionpack 4.2.1
Using globalid 0.3.5
Using activejob 4.2.1
Using mime-types 2.6.1
Using mail 2.6.3
Using actionmailer 4.2.1
Using activemodel 4.2.1
Using arel 6.0.0
Using activerecord 4.2.1
Using debug_inspector 0.0.2
Using binding_of_caller 0.7.2
Using columnize 0.9.0
Using byebug 5.0.0
Using coffee-script-source 1.9.1.1
Using execjs 2.5.2
Using coffee-script 2.4.1
Using thor 0.19.1
Using railties 4.2.1
Using coffee-rails 4.1.0
Using multi_json 1.11.0
Using jbuilder 2.2.16
Using jquery-rails 4.0.3
Using bundler 1.9.9
Using sprockets 3.1.0
Using sprockets-rails 2.3.1
Using rails 4.2.1
Using rdoc 4.2.0
Using sass 3.4.14
Using tilt 1.4.1
Using sass-rails 5.0.3
Using sdoc 0.4.1
Using sqlite3 1.3.10
Using turbolinks 2.5.3
Using tzinfo-data 1.2015.4
Using uglifier 2.7.1
Using web-console 2.1.2
Bundle complete! 12 Gemfile dependencies, 54 gems now installed.
Use `bundle show [gemname]` to see where a bundled gem is installed.

--

then rails s, and I get these errors

C:\rubyblah\qwerty>rails s
C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/sqlite3-1.3.10-x64-mingw32/lib/sqlite3.rb
:6:in `require': cannot load such file -- sqlite3/sqlite3_native (LoadError)
        from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/sqlite3-1.3.10-x64-mingw32/l
ib/sqlite3.rb:6:in `rescue in <top (required)>'
        from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/sqlite3-1.3.10-x64-mingw32/l
ib/sqlite3.rb:2:in `<top (required)>'
        from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/bundler-1.9.9/lib/bundler/ru
ntime.rb:76:in `require'
        from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/bundler-1.9.9/lib/bundler/ru
ntime.rb:76:in `block (2 levels) in require'
        from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/bundler-1.9.9/lib/bundler/ru
ntime.rb:72:in `each'
        from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/bundler-1.9.9/lib/bundler/ru
ntime.rb:72:in `block in require'
        from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/bundler-1.9.9/lib/bundler/ru
ntime.rb:61:in `each'
        from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/bundler-1.9.9/lib/bundler/ru
ntime.rb:61:in `require'
        from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/bundler-1.9.9/lib/bundler.rb
:134:in `require'
        from C:/rubyblah/qwerty/config/application.rb:7:in `<top (required)>'
        from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/railties-4.2.1/lib/rails/com
mands/commands_tasks.rb:78:in `require'
        from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/railties-4.2.1/lib/rails/com
mands/commands_tasks.rb:78:in `block in server'
        from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/railties-4.2.1/lib/rails/com
mands/commands_tasks.rb:75:in `tap'
        from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/railties-4.2.1/lib/rails/com
mands/commands_tasks.rb:75:in `server'
        from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/railties-4.2.1/lib/rails/com
mands/commands_tasks.rb:39:in `run_command!'
        from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/railties-4.2.1/lib/rails/com
mands.rb:17:in `<top (required)>'
        from bin/rails:4:in `require'
        from bin/rails:4:in `<main>'

C:\rubyblah\qwerty>

I found this regarding the first error

cannot load such file -- sqlite3/sqlite3_native (LoadError) on ruby on rails

So I edited the corresponding gemspec file as instructed

C:\>dir sql*.gemspec /s/b
C:\Ruby22-x64\lib\ruby\gems\2.2.0\specifications\sqlite3-1.3.10-x64-mingw32.gems
pec

I edit that gemspec file changing s.require_paths = ["lib"] to s.require_paths = ["lib/sqlite3_native"]

Then when I run rails s, I get a whole new bunch of errors

C:\rubyblah\qwerty>rails s
C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/nokogiri-1.6.6.2-x64-mingw32/lib/nokogiri
.rb:29:in `require': cannot load such file -- nokogiri/nokogiri (LoadError)
        from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/nokogiri-1.6.6.2-x64-mingw32
/lib/nokogiri.rb:29:in `rescue in <top (required)>'
        from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/nokogiri-1.6.6.2-x64-mingw32
/lib/nokogiri.rb:25:in `<top (required)>'
        from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/loofah-2.0.2/lib/loofah.rb:3
:in `require'
        from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/loofah-2.0.2/lib/loofah.rb:3
:in `<top (required)>'
        from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/rails-html-sanitizer-1.0.2/l
ib/rails-html-sanitizer.rb:2:in `require'
        from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/rails-html-sanitizer-1.0.2/l
ib/rails-html-sanitizer.rb:2:in `<top (required)>'
        from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/actionview-4.2.1/lib/action_
view/helpers/sanitize_helper.rb:3:in `require'
        from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/actionview-4.2.1/lib/action_
view/helpers/sanitize_helper.rb:3:in `<top (required)>'
        from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/actionview-4.2.1/lib/action_
view/helpers/text_helper.rb:32:in `<module:TextHelper>'
        from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/actionview-4.2.1/lib/action_
view/helpers/text_helper.rb:29:in `<module:Helpers>'
        from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/actionview-4.2.1/lib/action_
view/helpers/text_helper.rb:6:in `<module:ActionView>'
        from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/actionview-4.2.1/lib/action_
view/helpers/text_helper.rb:4:in `<top (required)>'
        from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/actionview-4.2.1/lib/action_
view/helpers/form_tag_helper.rb:18:in `<module:FormTagHelper>'
        from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/actionview-4.2.1/lib/action_
view/helpers/form_tag_helper.rb:14:in `<module:Helpers>'
        from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/actionview-4.2.1/lib/action_
view/helpers/form_tag_helper.rb:8:in `<module:ActionView>'
        from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/actionview-4.2.1/lib/action_
view/helpers/form_tag_helper.rb:6:in `<top (required)>'
        from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/actionview-4.2.1/lib/action_
view/helpers/form_helper.rb:4:in `require'
        from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/actionview-4.2.1/lib/action_
view/helpers/form_helper.rb:4:in `<top (required)>'
        from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/actionview-4.2.1/lib/action_
view/helpers.rb:50:in `<module:Helpers>'
        from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/actionview-4.2.1/lib/action_
view/helpers.rb:4:in `<module:ActionView>'
        from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/actionview-4.2.1/lib/action_
view/helpers.rb:3:in `<top (required)>'
        from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/sprockets-rails-2.3.1/lib/sp
rockets/rails/legacy_asset_tag_helper.rb:7:in `<module:LegacyAssetTagHelper>'
        from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/sprockets-rails-2.3.1/lib/sp
rockets/rails/legacy_asset_tag_helper.rb:6:in `<module:Rails>'
        from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/sprockets-rails-2.3.1/lib/sp
rockets/rails/legacy_asset_tag_helper.rb:4:in `<module:Sprockets>'
        from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/sprockets-rails-2.3.1/lib/sp
rockets/rails/legacy_asset_tag_helper.rb:3:in `<top (required)>'
        from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/sprockets-rails-2.3.1/lib/sp
rockets/rails/helper.rb:54:in `require'
        from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/sprockets-rails-2.3.1/lib/sp
rockets/rails/helper.rb:54:in `<module:Helper>'
        from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/sprockets-rails-2.3.1/lib/sp
rockets/rails/helper.rb:7:in `<module:Rails>'
        from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/sprockets-rails-2.3.1/lib/sp
rockets/rails/helper.rb:6:in `<module:Sprockets>'
        from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/sprockets-rails-2.3.1/lib/sp
rockets/rails/helper.rb:5:in `<top (required)>'
        from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/sprockets-rails-2.3.1/lib/sp
rockets/railtie.rb:6:in `require'
        from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/sprockets-rails-2.3.1/lib/sp
rockets/railtie.rb:6:in `<top (required)>'
        from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/sass-rails-5.0.3/lib/sass/ra
ils/railtie.rb:3:in `require'
        from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/sass-rails-5.0.3/lib/sass/ra
ils/railtie.rb:3:in `<top (required)>'
        from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/sass-rails-5.0.3/lib/sass/ra
ils.rb:11:in `require'
        from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/sass-rails-5.0.3/lib/sass/ra
ils.rb:11:in `<top (required)>'
        from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/sass-rails-5.0.3/lib/sass-ra
ils.rb:1:in `require'
        from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/sass-rails-5.0.3/lib/sass-ra
ils.rb:1:in `<top (required)>'
        from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/bundler-1.9.9/lib/bundler/ru
ntime.rb:76:in `require'
        from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/bundler-1.9.9/lib/bundler/ru
ntime.rb:76:in `block (2 levels) in require'
        from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/bundler-1.9.9/lib/bundler/ru
ntime.rb:72:in `each'
        from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/bundler-1.9.9/lib/bundler/ru
ntime.rb:72:in `block in require'
        from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/bundler-1.9.9/lib/bundler/ru
ntime.rb:61:in `each'
        from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/bundler-1.9.9/lib/bundler/ru
ntime.rb:61:in `require'
        from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/bundler-1.9.9/lib/bundler.rb
:134:in `require'
        from C:/rubyblah/qwerty/config/application.rb:7:in `<top (required)>'
        from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/railties-4.2.1/lib/rails/com
mands/commands_tasks.rb:78:in `require'
        from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/railties-4.2.1/lib/rails/com
mands/commands_tasks.rb:78:in `block in server'
        from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/railties-4.2.1/lib/rails/com
mands/commands_tasks.rb:75:in `tap'
        from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/railties-4.2.1/lib/rails/com
mands/commands_tasks.rb:75:in `server'
        from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/railties-4.2.1/lib/rails/com
mands/commands_tasks.rb:39:in `run_command!'
        from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/railties-4.2.1/lib/rails/com
mands.rb:17:in `<top (required)>'
        from bin/rails:4:in `require'
        from bin/rails:4:in `<main>'

C:\rubyblah\qwerty>

解决方案

One option is downgrading ruby to a version that is stable/working with windows. The other option is installing a linux VM and installing Ruby there.

You need to install a version of Ruby that is stable with Windows.

Not the latest version of Ruby. As of writing the latest is 2.2.2 and not stable with Windows.

And even if you are on a 64bit machine, the stable Ruby for Windows is a 32bit.

You want Ruby 2.1.X e.g. Ruby 2.1.6 (the latest 2.1.x is fine, 2.1.6) And you want the 32bit version

http://dl.bintray.com/oneclick/rubyinstaller/rubyinstaller-2.1.6.exe

That is mentioned here http://rubyinstaller.org/downloads/ "we recommend you use Ruby 2.1.X installers. These provide a stable language and a extensive list of packages (gems) that are compatible and updated.

However, not all packages (gems) are maintained. Some older packages may not be compatible with newer versions of Ruby and RubyInstaller.

The 64-bit versions of Ruby are relatively new on the Windows area and not all the packages have been updated to be compatible with it. To use this version you will require some knowledge about compilers and solving dependency issues, which might be too complicated if you just want to play with the language."

Take note of that instruction

So remove any current Ruby you have.

To remove Ruby, you go to the start menu..Ruby.. and click Uninstall.

That should uninstall Rails too.

And remove any devkit. The devkit executable installs by extraction to a folder you specify so just rmdir/remove that folder.

Now install that stable ruby.. 2.1.6 32bit Install rails and the devkit

The command to install rails

gem install rails

An to install the devkit make sure you have the correct one

e.g.

http://rubyinstaller.org/downloads/

WHICH DEVELOPMENT KIT?
....

Ruby 1.8.6 to 1.9.3: tdm-32-4.5.2  

Ruby 2.0.0 and above (32bits): mingw64-32-4.7.2  

Ruby 2.0.0 and above x64 (64bits): mingw64-64-4.7.2  

So you want

Ruby 2.0.0 and above (32bits): mingw64-32-4.7.2

Look at the available devkits

DEVELOPMENT KIT

For use with Ruby 1.8.7 and 1.9.3:

DevKit-tdm-32-4.5.2-20111229-1559-sfx.exe
For use with Ruby 2.0 and above (32bits version only):

DevKit-mingw64-32-4.7.2-20130224-1151-sfx.exe
For use with Ruby 2.0 and above (x64 - 64bits only)

DevKit-mingw64-64-4.7.2-20130224-1432-sfx.exe

You want

DevKit-tdm-32-4.5.2-20111229-1559-sfx.exe
For use with Ruby 2.0 and above (32bits version only):

http://dl.bintray.com/oneclick/rubyinstaller/DevKit-mingw64-32-4.7.2-20130224-1151-sfx.exe

Follow the instructions from here to install devkit https://github.com/oneclick/rubyinstaller/wiki/Development-Kit

So say you put it in c:\devkit

c:\devkit>ruby dk.rb init

c:\devkit>ruby dk.rb install

you can run this command though i don't think it's necessary c:\sdfsd>gem install json --platform=ruby

so now you have ruby and rails and the devkit installed

rails new <project name>

cd <project name>

bundle install

rails s

http://localhost:3000 (in your browser)

and it says 'welcome aboard'

这篇关于在 Windows 中, rails s 给出了 3 个不同的错误,我修复了一个并获得了更多错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆