论坛首页 编程语言技术论坛

诡异的"already initialized constant OPTIONS"及解决方案

浏览 3288 次
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
作者 正文
   发表时间:2007-10-15   最后修改:2009-10-16
最近要为公司一个程序加数据统计代码。在Ubuntu环境下checkout下整个程序,发现无法打开server,出错信息如下:

=> Booting Mongrel (use 'script/server webrick' to force WEBrick)
=> Rails application starting on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
** Ruby version is not up-to-date; loading cgi_multipart_eof_fix
** Starting Mongrel listening at 0.0.0.0:3000
** Starting Rails with development environment...
ActiveScaffold: extending RESTful routes for students
ActiveScaffold: extending RESTful routes for student_profiles
ActiveScaffold: extending RESTful routes for discount_codes
ActiveScaffold: extending RESTful routes for trainers
ActiveScaffold: extending RESTful routes for trainer_profiles
ActiveScaffold: extending RESTful routes for certified_modules
ActiveScaffold: extending RESTful routes for scenarios
Exiting
/var/lib/gems/1.8/gems/rails-1.2.4/lib/commands/servers/mongrel.rb:15: warning: already
initialized constant OPTIONS
/var/lib/gems/1.8/gems/rails-1.2.4/lib/commands/servers/mongrel.rb:18: undefined method
`options' for []:Array (NoMethodError)
        from /usr/lib/ruby/1.8/rubygems/custom_require.rb:33:in `gem_original_require'
        from /usr/lib/ruby/1.8/rubygems/custom_require.rb:33:in `require'
        from /var/lib/gems/1.8/gems/activesupport-
1.4.3/lib/active_support/dependencies.rb:495:in `require'
        from /var/lib/gems/1.8/gems/activesupport-
1.4.3/lib/active_support/dependencies.rb:342:in `new_constants_in'
        from /var/lib/gems/1.8/gems/activesupport-
1.4.3/lib/active_support/dependencies.rb:495:in `require'
        from /var/lib/gems/1.8/gems/rails-1.2.4/lib/commands/server.rb:39
        from /usr/lib/ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require'
        from /usr/lib/ruby/1.8/rubygems/custom_require.rb:27:in `require'
        from script/server:3



开始以为是环境出错,但发现新建的空项目可以运行。

于是搜索:"warning: already initialized constant OPTIONS"
得到
http://blog.1sters.com/?action=show&id=32

http://www.dansketcher.com/2007/05/07/warning-already-initialized-constant-options/
解决方法都说是缺少app中使用的gem,但查看environment.rb,安装所有require,server依然启动不起来。

搜索:"undefined method `options' for []:Array (NoMethodError)"
得到:
http://bpdp.wordpress.com/2007/08/27/what-does-mongrelrb15-warning-already-initialized-constant
-options-means/

作者的解决方案如下:
"All I have to do is remove all of the plugins (I just move it to directory
$RAILS_ROOT/tmp/plugins which I created myself) and then start move it one by one to
$RAILS_ROOT/vendor/plugins and test it using $RAILS_ROOT/script/server webrick.Then I found that
activemerchant is my problem. I need builder gem.It is all easy but the error messages was
really a mess"

按照他的方法,我把$RAILS_ROOT/vendor/plugins中的所有文件剪切出来再逐一拷贝回去并测试服务器,最终
发现是tzinfo_timezone导致的出错。

安装tzinfo_timezone,启动server,问题解决。

简单的问题,不过真是“ error messages was really a mess
顺便说下,
http://blog.1sters.com/?action=show&id=32中说在environment.rb添加“require ‘nonexistingfile’”
可启动服务器,实际上这是复现这个错误的方法。


找可以运行的环境,查看安装的gem list,把缺少的安装一遍就行。上面好笨~~~

   发表时间:2007-11-12  
rails-1.2.4
update to 1.2.5
update your mongrel.
0 请登录后投票
论坛首页 编程语言技术版

跳转论坛:
Global site tag (gtag.js) - Google Analytics