启动 Rails 服务器时出错 [英] Error in starting rails server

查看:58
本文介绍了启动 Rails 服务器时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近从我的 Windows 机器上安装了 rubyrubyonrails.当我使用 rails new FirstApp 创建一个新的 rails 项目时,它工作正常,但是当我尝试使用 rails s 启动 rails 服务器时,它会引发我下面提到的错误:

C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/activesupport-4.1.0.beta1/lib/active_support/core_ext/time/zones.rb:70:in `rescue in find_zone!': uninitial化常量 TZInfo::InvalidTimezoneIdentifier (NameError)来自 C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/activesupport-4.1.0.beta1/lib/active_support/core_ext/time/zones.rb:55:in `find_zone!'来自 C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/activesupport-4.1.0.beta1/lib/active_support/railtie.rb:20:in `block in '来自 C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/railties-4.1.0.beta1/lib/rails/initializable.rb:30:in`instance_exec'来自 C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/railties-4.1.0.beta1/lib/rails/initializable.rb:30:在运行"中来自 C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/railties-4.1.0.beta1/lib/rails/initializable.rb:55:in `block in run_initializers'来自 C:/RailsInstaller/Ruby2.0.0/lib/ruby/2.0.0/tsort.rb:150:in `block in tsort_each'来自 C:/RailsInstaller/Ruby2.0.0/lib/ruby/2.0.0/tsort.rb:183:in `block (2 个级别)在 each_strongly_connected_component'来自 C:/RailsInstaller/Ruby2.0.0/lib/ruby/2.0.0/tsort.rb:219:in `each_strongly_connected_component_from'来自 C:/RailsInstaller/Ruby2.0.0/lib/ruby/2.0.0/tsort.rb:182:in `block in each_strongly_connected_component'来自 C:/RailsInstaller/Ruby2.0.0/lib/ruby/2.0.0/tsort.rb:180:in `each'来自 C:/RailsInstaller/Ruby2.0.0/lib/ruby/2.0.0/tsort.rb:180:in `each_strongly_connected_component'来自 C:/RailsInstaller/Ruby2.0.0/lib/ruby/2.0.0/tsort.rb:148:in `tsort_e啊'来自 C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/railties-4.1.0.beta1/lib/rails/initializable.rb:54:in`run_initializers'来自 C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/railties-4.1.0.beta1/lib/rails/application.rb:285:在`初始化!'来自 E:/rubydemo/test3/config/environment.rb:5:in `'来自 E:/rubydemo/test3/config.ru:3:in `require'来自 E:/rubydemo/test3/config.ru:3:in ‘block in <main>’来自 C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/rack-1.5.2/lib/rack/builder.rb:55:in`instance_eval'来自 C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/rack-1.5.2/lib/rack/builder.rb:55:在`初始化'来自 E:/rubydemo/test3/config.ru:in `new'来自 E:/rubydemo/test3/config.ru:in ‘<main>’来自 C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/rack-1.5.2/lib/rack/builder.rb:49:in`eval'来自 C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/rack-1.5.2/lib/rack/builder.rb:49:in`new_from_string'来自 C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/rack-1.5.2/lib/rack/builder.rb:40:in`parse_file'来自 C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/rack-1.5.2/lib/rack/server.rb:277:in`build_app_and_options_from_config'来自 C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/rack-1.5.2/lib/rack/server.rb:199:in`app'来自 C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/railties-4.1.0.beta1/lib/rails/commands/server.rb:50:in`app'来自 C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/rack-1.5.2/lib/rack/server.rb:314:in`wrapped_app'来自 C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/railties-4.1.0.beta1/lib/rails/commands/server.rb:130:in`log_to_stdout'来自 C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/railties-4.1.0.beta1/lib/rails/commands/server.rb:67:in `start'来自 C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/railties-4.1.0.beta1/lib/rails/commands/commands_tasks.rb:81:在服务器中的块"中来自 C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/railties-4.1.0.beta1/lib/rails/commands/commands_tasks.rb:76:in`tap'来自 C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/railties-4.1.0.beta1/lib/rails/commands/commands_tasks.rb:76:in `server'来自 C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/railties-4.1.0.beta1/lib/rails/commands/commands_tasks.rb:40:in `run_command!'来自 C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/railties-4.1.0.beta1/lib/rails/commands.rb:17:in `'来自 bin/rails:4:in `require'来自 bin/rails:4:in `<main>'

谁能帮我理解这里的问题以及如何解决它?我正在使用 ruby 2.0.0p195 (2013-05-14) [i386-mingw32]Rails 4.1.0.beta1

解决方案

终于解决了这个问题.确保在 tzinfo-data 条目之前将 gem 'tzinfo' 添加到您的 Gemfile 中,一切都会开始工作.参考:https://github.com/rails/rails/issues/13553>

I recently fromatted my Windows machine and installed ruby and rubyonrails. When I create a new rails project using rails new FirstApp it works fine, but when I try to start the rails server using rails s it throws me the below mentioned error:

C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/activesupport-4.1.0.beta1/l
ib/active_support/core_ext/time/zones.rb:70:in `rescue in find_zone!': uninitial
ized constant TZInfo::InvalidTimezoneIdentifier (NameError)
        from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/activesupport-
4.1.0.beta1/lib/active_support/core_ext/time/zones.rb:55:in `find_zone!'
        from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/activesupport-
4.1.0.beta1/lib/active_support/railtie.rb:20:in `block in <class:Railtie>'
        from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/railties-4.1.0
.beta1/lib/rails/initializable.rb:30:in `instance_exec'
        from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/railties-4.1.0
.beta1/lib/rails/initializable.rb:30:in `run'
        from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/railties-4.1.0
.beta1/lib/rails/initializable.rb:55:in `block in run_initializers'
        from C:/RailsInstaller/Ruby2.0.0/lib/ruby/2.0.0/tsort.rb:150:in `block i
n tsort_each'
        from C:/RailsInstaller/Ruby2.0.0/lib/ruby/2.0.0/tsort.rb:183:in `block (
2 levels) in each_strongly_connected_component'
        from C:/RailsInstaller/Ruby2.0.0/lib/ruby/2.0.0/tsort.rb:219:in `each_st
rongly_connected_component_from'
        from C:/RailsInstaller/Ruby2.0.0/lib/ruby/2.0.0/tsort.rb:182:in `block i
n each_strongly_connected_component'
        from C:/RailsInstaller/Ruby2.0.0/lib/ruby/2.0.0/tsort.rb:180:in `each'
        from C:/RailsInstaller/Ruby2.0.0/lib/ruby/2.0.0/tsort.rb:180:in `each_st
rongly_connected_component'
        from C:/RailsInstaller/Ruby2.0.0/lib/ruby/2.0.0/tsort.rb:148:in `tsort_e
ach'
        from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/railties-4.1.0
.beta1/lib/rails/initializable.rb:54:in `run_initializers'
        from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/railties-4.1.0
.beta1/lib/rails/application.rb:285:in `initialize!'
        from E:/rubydemo/test3/config/environment.rb:5:in `<top (required)>'
        from E:/rubydemo/test3/config.ru:3:in `require'
        from E:/rubydemo/test3/config.ru:3:in `block in <main>'
        from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/rack-1.5.2/lib
/rack/builder.rb:55:in `instance_eval'
        from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/rack-1.5.2/lib
/rack/builder.rb:55:in `initialize'
        from E:/rubydemo/test3/config.ru:in `new'
        from E:/rubydemo/test3/config.ru:in `<main>'
        from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/rack-1.5.2/lib
/rack/builder.rb:49:in `eval'
        from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/rack-1.5.2/lib
/rack/builder.rb:49:in `new_from_string'
        from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/rack-1.5.2/lib
/rack/builder.rb:40:in `parse_file'
        from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/rack-1.5.2/lib
/rack/server.rb:277:in `build_app_and_options_from_config'
        from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/rack-1.5.2/lib
/rack/server.rb:199:in `app'
        from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/railties-4.1.0
.beta1/lib/rails/commands/server.rb:50:in `app'
        from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/rack-1.5.2/lib
/rack/server.rb:314:in `wrapped_app'
        from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/railties-4.1.0
.beta1/lib/rails/commands/server.rb:130:in `log_to_stdout'
        from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/railties-4.1.0
.beta1/lib/rails/commands/server.rb:67:in `start'
        from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/railties-4.1.0
.beta1/lib/rails/commands/commands_tasks.rb:81:in `block in server'
        from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/railties-4.1.0
.beta1/lib/rails/commands/commands_tasks.rb:76:in `tap'
        from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/railties-4.1.0
.beta1/lib/rails/commands/commands_tasks.rb:76:in `server'
        from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/railties-4.1.0
.beta1/lib/rails/commands/commands_tasks.rb:40:in `run_command!'
        from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/railties-4.1.0
.beta1/lib/rails/commands.rb:17:in `<top (required)>'
        from bin/rails:4:in `require'
        from bin/rails:4:in `<main>'

Can anyone help me understand the problem here and how to resolve it? I am using ruby 2.0.0p195 (2013-05-14) [i386-mingw32] and Rails 4.1.0.beta1

解决方案

Finally, got rid of the issue. Make sure to add gem 'tzinfo' to your Gemfile before the tzinfo-data entry and everything will start working. Ref: https://github.com/rails/rails/issues/13553

这篇关于启动 Rails 服务器时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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