ruby-on-rails - 第一次运行 Rails 服务器时出错

标签 ruby-on-rails ruby rubygems server

我刚刚开始学习 Rails,目前正在通过 Lynda 类(class)Kevin Skoglund 的 Ruby on Rails 3 基本培训进行学习。在我到达的这一点上,我们正在尝试构建我们的第一个 Web 应用程序,并且系统指示我们通过输入 rails server 来创建我们的服务器,正如您所看到的那样。当我输入该内容时,会出现整个加载错误困惑,我不知道如何修复它。

C:\Users\Bryan\Documents\Sites\simple_cms>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.3/lib/loofah.rb:3:in `require'
    from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/loofah-2.0.3/lib/loofah.rb:3:in `<top (required)>'
    from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/rails-html-sanitizer-1.0.2/lib/rails-html-sanitizer.rb:2:in `require'
    from 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)>'
    from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/actionview-4.2.4/lib/action_view/helpers/sanitize_helper.rb:3:in `require'
    from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/actionview-4.2.4/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.4/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.4/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.4/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.4/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.4/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.4/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.4/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.4/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.4/lib/action_view/helpers/form_helper.rb:4:in `require'
    from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/actionview-4.2.4/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.4/lib/action_view/helpers.rb:50:in `<module:Helpers>'
    from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/actionview-4.2.4/lib/action_view/helpers.rb:4:in `<module:ActionView>'
    from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/actionview-4.2.4/lib/action_view/helpers.rb:3:in `<top (required)>'
    from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/sprockets-rails-2.3.3/lib/sprockets/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.3/lib/sprockets/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.3/lib/sprockets/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.3/lib/sprockets/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.3/lib/sprockets/rails/helper.rb:45:in `require'
    from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/sprockets-rails-2.3.3/lib/sprockets/rails/helper.rb:45:in `<module:Helper>'
    from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/sprockets-rails-2.3.3/lib/sprockets/rails/helper.rb:7:in `<module:Rails>'
    from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/sprockets-rails-2.3.3/lib/sprockets/rails/helper.rb:6:in `<module:Sprockets>'
    from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/sprockets-rails-2.3.3/lib/sprockets/rails/helper.rb:5:in `<top (required)>'
    from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/sprockets-rails-2.3.3/lib/sprockets/railtie.rb:6:in `require'
    from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/sprockets-rails-2.3.3/lib/sprockets/railtie.rb:6:in `<top (required)>'
    from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/sass-rails-5.0.4/lib/sass/rails/railtie.rb:3:in `require'
    from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/sass-rails-5.0.4/lib/sass/rails/railtie.rb:3:in `<top (required)>'
    from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/sass-rails-5.0.4/lib/sass/rails.rb:11:in `require'
    from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/sass-rails-5.0.4/lib/sass/rails.rb:11:in `<top (required)>'
    from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/sass-rails-5.0.4/lib/sass-rails.rb:1:in `require'
    from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/sass-rails-5.0.4/lib/sass-rails.rb:1:in `<top (required)>'
    from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/bundler-1.10.6/lib/bundler/runtime.rb:76:in `require'
    from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/bundler-1.10.6/lib/bundler/runtime.rb:76:in `block (2 levels) in require'
    from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/bundler-1.10.6/lib/bundler/runtime.rb:72:in `each'
    from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/bundler-1.10.6/lib/bundler/runtime.rb:72:in `block in require'
    from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/bundler-1.10.6/lib/bundler/runtime.rb:61:in `each'
    from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/bundler-1.10.6/lib/bundler/runtime.rb:61:in `require'
    from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/bundler-1.10.6/lib/bundler.rb:134:in `require'
    from C:/Users/Bryan/Documents/Sites/simple_cms/config/application.rb:7:in `<top (required)>'
    from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/railties-4.2.4/lib/rails/commands/commands_tasks.rb:78:in `require'
    from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/railties-4.2.4/lib/rails/commands/commands_tasks.rb:78:in `block in server'
    from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/railties-4.2.4/lib/rails/commands/commands_tasks.rb:75:in `tap'
    from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/railties-4.2.4/lib/rails/commands/commands_tasks.rb:75:in `server'
    from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/railties-4.2.4/lib/rails/commands/commands_tasks.rb:39:in `run_command!'
    from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/railties-4.2.4/lib/rails/commands.rb:17:in `<top (required)>'
    from bin/rails:4:in `require'
    from bin/rails:4:in `<main>'

 C:\Users\Bryan\Documents\Sites\simple_cms>

最佳答案

确保您的 Gemfile 包含:

gem 'nokogiri'

然后运行bundle install命令,如果仍然遇到相同的错误,请尝试运行rails s,然后重新启动计算机以确保gemset已更新。

如果问题仍然出现,请再次编辑您的 Gemfile 并输入:

gem 'nokogiri', :require => false

运行bundle install并尝试运行rails s

编辑

刚刚注意到您是 Windows 用户并使用 ruby​​ 2.2,其中 nokogiri 尚未为您的环境编译,抱歉: https://github.com/sparklemotion/nokogiri/issues/1256

尝试将您的 ruby​​ 降级到 2.0.0。

关于ruby-on-rails - 第一次运行 Rails 服务器时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33110071/

相关文章:

javascript - 使用 typeahead.js 创建可点击的动态链接

ruby - 为什么赋值的值总是参数的值?

ruby-on-rails - 运行 rails new 时出现 Rubygems 问题

javascript - Rails 功能测试assert_select javascript respond_to

ruby-on-rails - 如果 ActiveRecord::Base#create 在 3.2.13 中已弃用,我该如何使用它?

ruby-on-rails - Rails 创建操作在应该呈现新操作时重定向到索引

ruby-on-rails - 每次我在 Rails 3 上遇到异常时都可以执行一个方法吗?

ruby - 如何使用 RDoc 标记呈现逐字/代码/前置加号?

rubygems - therubyracer安装错误

ruby - 通过 macports 安装了 fxruby,现在 ruby​​gems 坏了