【问题标题】:thin web server generates error uninitialized constant ActiveSupport::Dependencies when servicing request瘦 Web 服务器在服务请求时生成错误未初始化常量 ActiveSupport::Dependencies
【发布时间】:2012-02-12 21:37:21
【问题描述】:

我在这方面被困了一段时间,并阅读了 Thin 论坛,搜索了我能想到的所有内容,尝试查看我是否使用了错误的 gem 版本,所以我希望有人能建议我如何调试这个问题。

我用这个命令行启动 Thin:

 thin start -C /root/myapp/config/thin.yml -e production -d --adapter rack 

我正在使用 Rails 3.0.3 和 Ruby 1.9.2-p290 的 Amazon EC2 上的 Thin Web 服务器运行 nginx。 Nginx 和 Thin 运行良好,但是当从 nginx 向 Thin 发送 HTTP 请求时,Thin 踢出以下错误并且 Nginx reqports "502 Bad Gateway":

 !! Unexpected error while processing request: uninitialized constant      ActiveSupport::Dependencies
 uninitialized constant ActiveSupport::Dependencies
/usr/local/rvm/gems/ruby-1.9.2-p290/gems/actionpack-3.0.3/lib/action_dispatch/middleware/stack.rb:9:in `initialize'
/usr/local/rvm/gems/ruby-1.9.2-p290/gems/actionpack-3.0.3/lib/action_dispatch/middleware/stack.rb:67:in `new'
/usr/local/rvm/gems/ruby-1.9.2-p290/gems/actionpack-3.0.3/lib/action_dispatch/middleware/stack.rb:67:in `use'
/usr/local/rvm/gems/ruby-1.9.2-p290/gems/railties-3.0.3/lib/rails/application.rb:190:in `block in default_middleware_stack'
/usr/local/rvm/gems/ruby-1.9.2-p290/gems/railties-3.0.3/lib/rails/application.rb:189:in `tap'
/usr/local/rvm/gems/ruby-1.9.2-p290/gems/railties-3.0.3/lib/rails/application.rb:189:in `default_middleware_stack'
/usr/local/rvm/gems/ruby-1.9.2-p290/gems/railties-3.0.3/lib/rails/application.rb:161:in `app'
/usr/local/rvm/gems/ruby-1.9.2-p290/gems/railties-3.0.3/lib/rails/application.rb:168:in `call'
/usr/local/rvm/gems/ruby-1.9.2-p290/gems/railties-3.0.3/lib/rails/application.rb:77:in `method_missing'
/usr/local/rvm/gems/ruby-1.9.2-p290/gems/thin-1.2.7/lib/thin/connection.rb:76:in `block in pre_process'
/usr/local/rvm/gems/ruby-1.9.2-p290/gems/thin-1.2.7/lib/thin/connection.rb:74:in `catch'
/usr/local/rvm/gems/ruby-1.9.2-p290/gems/thin-1.2.7/lib/thin/connection.rb:74:in `pre_process'
/usr/local/rvm/gems/ruby-1.9.2-p290/gems/thin-1.2.7/lib/thin/connection.rb:57:in `process'
/usr/local/rvm/gems/ruby-1.9.2-p290/gems/thin-1.2.7/lib/thin/connection.rb:42:in `receive_data'
/usr/local/rvm/gems/ruby-1.9.2-p290/gems/eventmachine-0.12.10/lib/eventmachine.rb:256:in `run_machine'
/usr/local/rvm/gems/ruby-1.9.2-p290/gems/eventmachine-0.12.10/lib/eventmachine.rb:256:in `run'
/usr/local/rvm/gems/ruby-1.9.2-p290/gems/thin-1.2.7/lib/thin/backends/base.rb:57:in `start'
/usr/local/rvm/gems/ruby-1.9.2-p290/gems/thin-1.2.7/lib/thin/server.rb:156:in `start'
/usr/local/rvm/gems/ruby-1.9.2-p290/gems/thin-1.2.7/lib/thin/controllers/controller.rb:80:in `start'
/usr/local/rvm/gems/ruby-1.9.2-p290/gems/thin-1.2.7/lib/thin/runner.rb:177:in `run_command'
/usr/local/rvm/gems/ruby-1.9.2-p290/gems/thin-1.2.7/lib/thin/runner.rb:143:in `run!'
/usr/local/rvm/gems/ruby-1.9.2-p290/gems/thin-1.2.7/bin/thin:6:in `<top (required)>'
/usr/local/rvm/gems/ruby-1.9.2-p290/bin/thin:19:in `load'
/usr/local/rvm/gems/ruby-1.9.2-p290/bin/thin:19:in `<main>'

这是我的宝石清单:

* 本地宝石 *

 abstract (1.0.0)
 actionmailer (3.0.3)
 actionpack (3.0.3)
 activemodel (3.0.3)
 activerecord (3.0.3)
 activeresource (3.0.3)
 activesupport (3.0.3)
 arel (2.0.10)
 builder (2.1.2)
 bundler (1.0.10 ruby)
 cgi_multipart_eof_fix (2.5.0)
 daemons (1.0.10)
 erubis (2.6.6)
 eventmachine (0.12.10)
 fastthread (1.0.7)
 gem_plugin (0.2.3)
 i18n (0.6.0)
 mail (2.2.19)
 mime-types (1.17.2)
 mongrel (1.2.0.pre2)
 multi_json (1.0.4)
 mysql2 (0.2.18, 0.2.17)
 polyglot (0.3.3)
 rack (1.2.5, 1.2.4)
 rack-cache (1.0)
 rack-mount (0.6.14)
 rack-test (0.5.7)
 rails (3.0.3)
 railties (3.0.3)
 rake (0.9.2.2)
 redis (2.2.2)
 redis-namespace (1.0.3)
 resque (1.19.0)
 resque-access_worker_from_job (0.3.1)
 rmagick (2.13.1)
 sinatra (1.2.8)
 thin (1.2.7)
 thor (0.14.6)
 tilt (1.3.3)
 treetop (1.4.10)
 tzinfo (0.3.31)
 vegas (0.1.8)
 xmpp4r (0.5)

这是我的 config.ru 文件:

#!/usr/bin/env ruby
require 'thin'
require 'rack'

require ::File.expand_path('config/environment', File.dirname(__FILE__) )
run Myapp::Application

我也尝试过使用瘦 1.3.1,但没有成功。我试过 eventmachine-1.0.0.beta.2,但 Gemfile 一直想使用 0.12.10,即使我在运行 bundle install 之前删除了 Gemfile.lock。

我认为有关 ActiveSupport::Dependencies 的错误意味着我在某处使用了错误的库,但我不知道如何确定哪些库不正确。

有谁知道是什么导致了这个问题,或者有关于如何调试它的建议?

【问题讨论】:

  • 我已经取得了一些进展。我在 config.ru 中添加了 require 'active_support/dependencies',并且在离开时出现 ActiveSupport 错误。新错误是

标签: ruby-on-rails nginx amazon-ec2 thin


【解决方案1】:

这个link 让我走上了正确的道路。添加 require 'active_support/dependencies' 后,我接下来添加了 require 'action_controller' 到 config.ru,我可以通过我的 URI 访问 index.html。所以我的 config.ru 看起来像

 #!/usr/bin/env ruby
 require 'thin'
 require 'rack'
 require 'active_support/dependencies'
 require 'action_controller'

 require ::File.expand_path('config/environment', File.dirname(__FILE__) )
 run Myapp::Application

我不知道为什么需要这些要求,但它似乎可以解决问题。该链接说原因是如果您使用的是 Rails 3 beta gems。不确定我是否在使用此类宝石。

【讨论】:

    【解决方案2】:

    当我应该尝试使用与我的应用捆绑的 Thin 版本时,我使用包维护者的 Thin 版本遇到了这个错误:

    $  bundle exec thin start -C /root/myapp/config/thin.yml
    

    可悲的是,我正试图在 docker 容器中实现这一点,因此 RVM 让我很难从 entrypoint.sh 运行该命令。您可能想尝试完全删除软件包维护者版本 apt-get remove thin 并再次使用 bundle install 重新安装瘦。

    【讨论】:

      猜你喜欢
      • 2011-07-30
      • 2011-07-07
      • 1970-01-01
      • 2016-03-26
      • 2023-04-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多