为什么红宝石会崩溃?

发布于 2025-01-05 20:30:26 字数 1280 浏览 1 评论 0原文

我正在尝试使用 git://github.com/ericpaulbishop/redmine_git_hosting.git 中的“redmine_git_hosting”

当我尝试访问它时,我在 /var/log/apache2/ 中收到错误error.log

/lib/redmine/scm/adapters/git_adapter.rb:26: warning: already initialized constant GIT_BIN

我可以访问Redmine网站,但是如果我刷新我得到:

/usr/share/redmine_dev/lib/redmine/scm/adapters/git_adapter.rb:26: warning: already initialized constant GIT_BIN
[ pid=31351 thr=3075225872 file=ext/apache2/Hooks.cpp:817 time=2012-02-15 15:41:08.102 ]: The backend application (process 3677) did not send a valid HTTP response; instead, it sent nothing at all. It is possible that it has crashed; please check whether there are crashing bugs in this application.
[ pid=3677 thr=-609445668 file=utils.rb:176 time=2012-02-15 15:41:08.103 ]: *** Exception NameError in application (uninitialized constant Redmine::Scm::Adapters::CommandFailed) (process 3677, thread #<Thread:0xb75931b8>):

我收到500内部错误。

top 我可以看到一个 Ruby 进程被终止。

我的环境是:

  • Ubuntu 11.10
  • PostgreSQL 8.4
  • Apache2.20
  • Ruby 1.8.7
  • Redmine 1.3.0
  • Phusion 版本 3.0.11
  • Rails (2.3.14)
  • Rubygems 1.6.2

I am trying to use "redmine_git_hosting" from git://github.com/ericpaulbishop/redmine_git_hosting.git

When I try to access it I get an error in /var/log/apache2/error.log:

/lib/redmine/scm/adapters/git_adapter.rb:26: warning: already initialized constant GIT_BIN

I can access the Redmine site but then if I refresh I get:

/usr/share/redmine_dev/lib/redmine/scm/adapters/git_adapter.rb:26: warning: already initialized constant GIT_BIN
[ pid=31351 thr=3075225872 file=ext/apache2/Hooks.cpp:817 time=2012-02-15 15:41:08.102 ]: The backend application (process 3677) did not send a valid HTTP response; instead, it sent nothing at all. It is possible that it has crashed; please check whether there are crashing bugs in this application.
[ pid=3677 thr=-609445668 file=utils.rb:176 time=2012-02-15 15:41:08.103 ]: *** Exception NameError in application (uninitialized constant Redmine::Scm::Adapters::CommandFailed) (process 3677, thread #<Thread:0xb75931b8>):

I get a 500 Internal error.

From top I can see that one Ruby process was killed.

My environment is:

  • Ubuntu 11.10
  • PostgreSQL 8.4
  • Apache2.20
  • Ruby 1.8.7
  • Redmine 1.3.0
  • Phusion version 3.0.11
  • Rails (2.3.14)
  • Rubygems 1.6.2

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

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

发布评论

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

评论(1

木緿 2025-01-12 20:30:26

这似乎与针对 Chiliproject 分支报告的错误相同:https://www.chiliproject.org /问题/828

似乎这只发生在开发模式下,在第一个请求之后(从第二个请求开始),因为 Rails 会卸载您的模块,因此您不必每次进行更改时都重新启动应用程序。
在 application_controller 中,所有 scm 存储库类都会在每次请求时使用 require_dependency 再次加载。但是这些 scm 依赖的模块(例如 git_adapter 和 Abstract_adapter)会使用标准 ruby​​ 要求加载,因此它们不会再次加载。
因此,开发中会出现未初始化的持续错误。

建议的解决方案是

...从模块中删除需求并将它们集成到 application_controller :

  require_dependency 'redmine/scm/adapters/abstract_adapter'
  Redmine::Scm::Base.all.each do |scm|
      require_dependency "repository/#{scm.underscore}" 
      require_dependency "redmine/scm/adapters/#{scm.underscore}_adapter" 
  end

This appears to be the same bug as this one reported against the Chiliproject fork: https://www.chiliproject.org/issues/828

Seems this only happens in development mode, after the first request (from the second request on), since rails unloads your modules so you don't have to restart your app every time you make a change.
In the application_controller, all scm repository classes get loaded again with require_dependency on every request. But the modules these scm depend on like for example git_adapter and abstract_adapter get loaded with the standard ruby require, so they don't get loaded again.
Hence the uninitialized constant errors in development.

There the suggested solution was to

... remove the requires from within the modules and integrate them to the application_controller :

  require_dependency 'redmine/scm/adapters/abstract_adapter'
  Redmine::Scm::Base.all.each do |scm|
      require_dependency "repository/#{scm.underscore}" 
      require_dependency "redmine/scm/adapters/#{scm.underscore}_adapter" 
  end
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文