在最近的一次服务器切换之后,我在使用遗留代码(1.8)启动和运行RubyonRails应用程序时遇到了问题我正在运行/www/application/public/dispatch.fcgi对其进行测试
环境
Freebsd 10.0版
红宝石1.8.7 via rvm
ruby19-宝石-1.8.29
LightTPD-1.4.35平方米
已安装的gems列表
actionmailer (1.3.3)
actionpack (1.13.3)
actionwebservice (1.2.3)
activerecord (1.15.3)
activesupport (1.4.2)
bundler (1.6.3)
bundler-unload (1.0.2)
executable-hooks (1.3.2)
fcgi (0.9.2.1)
gem-wrappers (1.2.5)
rails (1.2.3)
rake (10.1.1)
rubygems-bundler (1.4.4)
rvm (1.11.3.9)
fastcgi.crash.log文件
[07/Jul/2014:17:01:45 :: 60555] starting
[07/Jul/2014:17:01:45 :: 60555] Dispatcher failed to catch: You have a nil object when you didn't expect it!
You might have expected an instance of Array.
The error occurred while evaluating nil.split (NoMethodError)
/usr/local/rvm/rubies/ruby-1.8.7-head/lib/ruby/1.8/cgi.rb:903:in `parse'
/usr/local/rvm/gems/ruby-1.8.7-head/gems/actionpack-1.13.3/lib/action_controller/cgi_ext/raw_post_data_fix.rb:45:in `initialize_query'
/usr/local/rvm/rubies/ruby-1.8.7-head/lib/ruby/1.8/cgi.rb:2286:in `initialize'
/usr/local/rvm/gems/ruby-1.8.7-head/gems/fcgi-0.9.2.1/lib/fcgi.rb:627:in `new'
/usr/local/rvm/gems/ruby-1.8.7-head/gems/fcgi-0.9.2.1/lib/fcgi.rb:627:in `each_cgi'
/usr/local/rvm/gems/ruby-1.8.7-head/gems/rails-1.2.3/lib/fcgi_handler.rb:141:in `process_each_request!'
/usr/local/rvm/gems/ruby-1.8.7-head/gems/rails-1.2.3/lib/fcgi_handler.rb:55:in `process!'
/usr/local/rvm/gems/ruby-1.8.7-head/gems/rails-1.2.3/lib/fcgi_handler.rb:25:in `process!'
/www/checkout/public/dispatch.fcgi:24
almost killed by this error
[07/Jul/2014:17:01:45 :: 60555] Dispatcher failed to catch: You have a nil object when you didn't expect it!
You might have expected an instance of Array.
The error occurred while evaluating nil.split (NoMethodError)
/usr/local/rvm/rubies/ruby-1.8.7-head/lib/ruby/1.8/cgi.rb:903:in `parse'
/usr/local/rvm/gems/ruby-1.8.7-head/gems/actionpack-1.13.3/lib/action_controller/cgi_ext/raw_post_data_fix.rb:45:in `initialize_query'
/usr/local/rvm/rubies/ruby-1.8.7-head/lib/ruby/1.8/cgi.rb:2286:in `initialize'
/usr/local/rvm/gems/ruby-1.8.7-head/gems/fcgi-0.9.2.1/lib/fcgi.rb:627:in `new'
/usr/local/rvm/gems/ruby-1.8.7-head/gems/fcgi-0.9.2.1/lib/fcgi.rb:627:in `each_cgi'
/usr/local/rvm/gems/ruby-1.8.7-head/gems/rails-1.2.3/lib/fcgi_handler.rb:141:in `process_each_request!'
/usr/local/rvm/gems/ruby-1.8.7-head/gems/rails-1.2.3/lib/fcgi_handler.rb:55:in `process!'
/usr/local/rvm/gems/ruby-1.8.7-head/gems/rails-1.2.3/lib/fcgi_handler.rb:25:in `process!'
/www/checkout/public/dispatch.fcgi:24
killed by this error
dispatch.fcgi的内容
#!/usr/local/bin/ruby18
#
# You may specify the path to the FastCGI crash log (a log of unhandled
# exceptions which forced the FastCGI instance to exit, great for debugging)
# and the number of requests to process before running garbage collection.
#
# By default, the FastCGI crash log is RAILS_ROOT/log/fastcgi.crash.log
# and the GC period is nil (turned off). A reasonable number of requests
# could range from 10-100 depending on the memory footprint of your app.
#
# Example:
# # Default log path, normal GC behavior.
# RailsFCGIHandler.process!
#
# # Default log path, 50 requests between GC.
# RailsFCGIHandler.process! nil, 50
#
# # Custom log path, normal GC behavior.
# RailsFCGIHandler.process! '/var/log/myapp_fcgi_crash.log'
#
require File.dirname(__FILE__) + "/../config/environment"
require 'fcgi_handler'
RailsFCGIHandler.process!
任何能解决这个问题的想法都将受到极大的赞赏。如有需要,请在评论中索取更多信息。
最佳答案
我强烈怀疑你的问题是Ruby1.8.7太新了。Ruby最近才采用了语义版本控制,1.8.7对标准库进行了大量的修改(在某种程度上,它是Ruby1.9的桥梁)
Ruby 1.8.7发布于2008年5月,也就是rails1.2.3发布一年多之后,那时1.2分支已经不再工作了看起来Rails2.2是支持Ruby1.8.7的第一个版本(这个http://www.devalot.com/articles/2012/03/ror-compatibility有一个Ruby版本与Rails版本的对照表。此外,还有很多与Ruby1.8.7相关的提交,虽然Rails2.1.2似乎包含了大部分修复程序,但这些提交在早期版本中并不存在)
降级到Ruby1.8.6应该会让你开始运行。
您还需要小心使用gem版本,例如rake 10.x不能使用以前的rails版本。不幸的是,Baulle在那时还不存在,所以可能需要一些猜测来找出正确的版本。