Search code examples
ruby-on-railsrubyfreebsdlighttpd

Ruby on Rails 1.23 application on Ruby 1.87 on FreeBSD keeps crashing on startup (fcgi)


After a recent server switch I am having troubles getting a Ruby on Rails app with legacy (1.8) code up and running. I am testing it by running /www/application/public/dispatch.fcgi

Enviroment

  • Freebsd 10.0
  • Ruby 1.8.7 via RVM
  • ruby19-gems-1.8.29
  • Lighttpd-1.4.35_2

List of installed 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

Contents of 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!

Any ideas how this can be solved will be greatly appreciated. Please request more information in comments if need.


Solution

  • I strongly suspect your problem is that ruby 1.8.7 is too new. Ruby only very recently adopted semantic versioning and 1.8.7 included a very significant number of changes to the standard library (it was in part intended as a bridge to ruby 1.9)

    Ruby 1.8.7 was released in May 2008, over a year after rails 1.2.3 was released - the 1.2 branch was no longer being worked on at that point. It seems like rails 2.2 was the first version to support ruby 1.8.7 (this http://www.devalot.com/articles/2012/03/ror-compatibility has a table of ruby versions against rails version. In addition there are a number of ruby 1.8.7 related commits that weren't in earlier versions, although rails 2.1.2 seems to include most of the fixes)

    Downgrading to ruby 1.8.6 should get you up and running.

    You'll also need to be careful with gem versions, for example rake 10.x won't work with a version of rails that old. Unfortunately bundler didn't exist back then so some guesswork may be required to figure out the right versions.