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

最近要为公司一个程序加数据统计代码。在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,把缺少的安装一遍就行。上面好笨~~~
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值