瘦 Web 服务器在服务请求时生成错误未初始化常量 ActiveSupport::Dependency

发布于 2024-12-27 14:21:24 字数 4240 浏览 1 评论 0原文

我已经在这个问题上停留了一段时间,并阅读了 Thin 论坛,用谷歌搜索了我能想到的所有内容,试图看看我是否使用了错误的 gem 版本,所以我希望有人可以建议我如何调试这个问题。

我使用以下命令行启动 Thin:

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

我在 Amazon EC2 上使用 Rails 3.0.3 和 Ruby 1.9.2-p290 运行 nginx 和 Thin Web 服务器。 Nginx 和 Thin 运行良好,但是当 HTTP 请求从 nginx 发送到 Thin 时,Thin 会抛出以下错误,并且 Nginx 请求端口“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>'

这是我的 gem 列表:

* LOCAL GEMS *

 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

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

我认为有关 ActiveSupport::Dependency 的错误意味着我在某个地方使用了错误的库,但我不知道如何找出哪些库不正确。

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

I've been stuck on this for a bit and have read the Thin forum, googled everything I can think of, tried to see if I've using the wrong gem versions, so I hope someone can suggest how I can debug this problem.

I start Thin with this command line:

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

I'm running nginx with the Thin web server on Amazon's EC2 with Rails 3.0.3 and Ruby 1.9.2-p290. Nginx and Thin run fine, but when an HTTP request is sent to Thin from nginx, Thin kicks out the following error and 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>'

Here is my gem list:

* LOCAL GEMS *

 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)

Here is my config.ru file:

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

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

I've also tried using thin 1.3.1 with no luck. I've tried eventmachine-1.0.0.beta.2, but the Gemfile keeps wanting to use 0.12.10, even though I deleted Gemfile.lock before running bundle install.

I think the error regarding ActiveSupport::Dependencies means that I am using the wrong libraries somewhere, but I don't know how to figure out which libraries are incorrect.

Does anyone know what is causing this problem, or have a suggestion on how to debug it?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

眼睛会笑 2025-01-03 14:21:24

这个链接让我走上了正确的道路。添加 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。不确定我是否使用这样的宝石。

This link set me on the right path. After adding require 'active_support/dependencies', I next added require 'action_controller'
to config.ru and I was able to access index.html through my URI. So my config.ru looks like

 #!/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

I have no idea why these requires are needed, but it seems to do the trick. The link says the reason is if you are using Rails 3 beta gems. Not sure if I am using such gems.

请别遗忘我 2025-01-03 14:21:24

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

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

遗憾的是,我试图让事情发生在 docker 容器中,所以 RVM 给了我一个从entrypoint.sh 运行该命令非常困难。您可能想尝试完全删除软件包维护者版本apt-get remove Thin并再次使用bundle install重新安装thin。

I'm hitting this error by using the package maintainer's version of thin when I should try to use the version of thin bundled with my app:

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

Sadly, I'm trying to get thing to happen in a docker container so RVM is giving me an impossibly hard time running that command from entrypoint.sh. You might want to try removing the package maintainers version altogether apt-get remove thin and reinstalling thin with bundle install again.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文