Script/server vs mongrel_rails start issue

I am having different results between when I start mongrel with script/
server and with mongrel_rails start.

When I run script/server to boot mongrel everything runs fine, no
errors.

When I run mongrel_rails start I get the following errors - verified
the problem on a fresh app and on two different environments (mac and
yes, windows server 2008). The actual line of fault changes but the
problem is always originating in /usr/local/bin/mongrel_rails:19

I would very much appreciate any ideas.

David

C:\webapps\creditcompare>mongrel_rails start -e production
** Starting Mongrel listening at 0.0.0.0:3000
** Starting Rails with production environment…
** Rails loaded.
** Loading any Rails specific GemPlugins
C:/Ruby187/lib/ruby/site_ruby/1.8/rubygems/source_index.rb:89:in
read': can't convert Hash into Integer (TypeError) from C:/Ruby187/lib/ruby/site_ruby/1.8/rubygems/ source_index.rb:89:inload_specification’
from C:/Ruby187/lib/ruby/site_ruby/1.8/rubygems/
source_index.rb:153:in load_gems_in' from C:/Ruby187/lib/ruby/site_ruby/1.8/rubygems/ source_index.rb:152:ineach’
from C:/Ruby187/lib/ruby/site_ruby/1.8/rubygems/
source_index.rb:152:in load_gems_in' from C:/Ruby187/lib/ruby/site_ruby/1.8/rubygems/ source_index.rb:149:inreverse_each’
from C:/Ruby187/lib/ruby/site_ruby/1.8/rubygems/
source_index.rb:149:in load_gems_in' from C:/Ruby187/lib/ruby/site_ruby/1.8/rubygems/ source_index.rb:345:inrefresh!’
from C:/Ruby187/lib/ruby/site_ruby/1.8/rubygems/
source_index.rb:78:in from_gems_in' from C:/Ruby187/lib/ruby/site_ruby/1.8/rubygems/ source_index.rb:60:infrom_installed_gems’
from C:/Ruby187/lib/ruby/gems/1.8/gems/gem_plugin-0.2.3/lib/
gem_plugin.rb:109:in load' from C:/Ruby187/lib/ruby/gems/1.8/gems/mongrel-1.1.5-x86- mingw32/bin/../lib/mongrel/configurator.rb:231:inload
plugins’
from C:/Ruby187/lib/ruby/gems/1.8/gems/mongrel-1.1.5-x86-
mingw32/bin/mongrel_rails:117:in cloaker_' from C:/Ruby187/lib/ruby/gems/1.8/gems/mongrel-1.1.5-x86- mingw32/bin/../lib/mongrel/configurator.rb:149:incall

from C:/Ruby187/lib/ruby/gems/1.8/gems/mongrel-1.1.5-x86-
mingw32/bin/…/lib/mongrel/configurator.rb:149:in list ener' from C:/Ruby187/lib/ruby/gems/1.8/gems/mongrel-1.1.5-x86- mingw32/bin/mongrel_rails:99:incloaker

from C:/Ruby187/lib/ruby/gems/1.8/gems/mongrel-1.1.5-x86-
mingw32/bin/…/lib/mongrel/configurator.rb:50:in `call’

    from C:/Ruby187/lib/ruby/gems/1.8/gems/mongrel-1.1.5-x86-

mingw32/bin/…/lib/mongrel/configurator.rb:50:in initi alize' from C:/Ruby187/lib/ruby/gems/1.8/gems/mongrel-1.1.5-x86- mingw32/bin/mongrel_rails:84:innew’
from C:/Ruby187/lib/ruby/gems/1.8/gems/mongrel-1.1.5-x86-
mingw32/bin/mongrel_rails:84:in run' from C:/Ruby187/lib/ruby/gems/1.8/gems/mongrel-1.1.5-x86- mingw32/bin/../lib/mongrel/command.rb:212:inrun’
from C:/Ruby187/lib/ruby/gems/1.8/gems/mongrel-1.1.5-x86-
mingw32/bin/mongrel_rails:281
from C:/Ruby187/bin/mongrel_rails:19:in `load’
from C:/Ruby187/bin/mongrel_rails:19

C:\webapps\creditcompare>

Sun Jun 13 13:12:32 -0700 2010: Error calling Dispatcher.dispatch
#<NoMethodError: You have a nil object when you didn’t expect it!
You might have expected an instance of ActiveRecord::Base.
The error occurred while evaluating nil.[]>
/usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/…/lib/mongrel/
cgi.rb:108:in send_cookies' /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel/ cgi.rb:136:inout’
/usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/…/lib/mongrel/
http_response.rb:65:in start' /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel/ cgi.rb:135:inout’
/usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/…/lib/mongrel/
rails.rb:81:in process' /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel.rb: 159:inprocess_client’
/usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/…/lib/mongrel.rb:
158:in each' /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel.rb: 158:inprocess_client’
/usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/…/lib/mongrel.rb:
285:in run' /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel.rb: 285:ininitialize’
/usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/…/lib/mongrel.rb:
285:in new' /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel.rb: 285:inrun’
/usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/…/lib/mongrel.rb:
268:in initialize' /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel.rb: 268:innew’
/usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/…/lib/mongrel.rb:
268:in run' /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel/ configurator.rb:282:inrun’
/usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/…/lib/mongrel/
configurator.rb:281:in each' /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel/ configurator.rb:281:inrun’
/usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/mongrel_rails:
128:in run' /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel/ command.rb:212:inrun’
/usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/mongrel_rails:281
/usr/local/bin/mongrel_rails:19:in `load’
/usr/local/bin/mongrel_rails:19

We ran into the same issue. You can follow the issue here.

https://rails.lighthouseapp.com/projects/8994/tickets/4690-mongrel-doesnt-work-with-rails-238

The fixes in the these posts did the trick for us:
Edgars Beigarts May 26th, 2010 @ 07:03 PM
bshand June 10th, 2010 @ 12:08 PM

Hope this helps!

-James

Hi,

First of all, I’m sorry for my English.

Looks like I found the reason of this problem:
I use REE 1.8.7, gem v=1.3.7
problem in
… /lib/ruby/site_ruby/1.8/rubygems/source_index.rb:89:in `read’:
can’t convert Hash into Integer (TypeError)

because code

if defined? Encoding then File.read file_name, :encoding => ‘UTF-8’

will work only with ruby 1.9
you can find difference here
Class: IO (Ruby 1.8.7)
http://ruby-doc.org/ruby-1.9/classes/IO.html#M000125

I found that ‘(defined? Encoding) == true’ because REXML::Encoding
loaded

Thanks James - wondering if you also found that config.cache_classes =
true
caused problems? I found that the patch + changing this setting to false
fixed things. config.cache_classes worked badly on 2.3.4 though also, so
is
a bit strange. As for the patch, I was finding that there was a nil
value
getting into the part of code where the patch is and that the .split was
failing as it was coming in as nil.split. Strange. Was there a reason
you
stayed with 2.3.8 rather than just staying on an older version of rails?

I found in my code this
‘include REXML’
removing this line helped to me fix this issue.
Try to find in your code inclusion Namspace with Encoding constant

Honestly we didn’t really have a reason to upgrade to 2.3.8 besides
trying to stay at the latest release. Since I figured out a way to
get it to run I decided to keep going with 2.3.8. As for the
cache_classes, I didn’t experience any behavior like that.

-James