Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

Mongrel doesn't work with rails 2.3.8

#4690

All my apps stopped working with "mongrel_rails" when I upgraded from 2.3.5 to 2.3.8, but script/server still works with mongrel.
To reproduce, create a new rails application with simple "render :text => 'Ok'" action and run "mongrel_rails start".

$ mongrel_rails start
** Starting Mongrel listening at 0.0.0.0:3000
** Starting Rails with development environment...
** Rails loaded.
** Loading any Rails specific GemPlugins
** Signals ready.  TERM => stop.  USR2 => restart.  INT => stop (no restart).
** Rails signals registered.  HUP => reload (without restart).  It might not work well.
** Mongrel 1.1.5 available at 0.0.0.0:3000
** Use CTRL-C to stop.
Tue May 25 20:24:52 +0300 2010: Error calling Dispatcher.dispatch #<NoMethodError: 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>
/Users/be/.gem/ruby/1.8/gems/actionpack-2.3.8/lib/action_controller/cgi_process.rb:54:in `dispatch_cgi'
/Users/be/.gem/ruby/1.8/gems/actionpack-2.3.8/lib/action_controller/dispatcher.rb:101:in `dispatch_cgi'
/Users/be/.gem/ruby/1.8/gems/actionpack-2.3.8/lib/action_controller/dispatcher.rb:27:in `dispatch'
/Users/be/.gem/ruby/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel/rails.rb:76:in `process'
/Users/be/.gem/ruby/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel/rails.rb:74:in `synchronize'
/Users/be/.gem/ruby/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel/rails.rb:74:in `process'
/Users/be/.gem/ruby/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel.rb:159:in `process_client'
/Users/be/.gem/ruby/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel.rb:158:in `each'
/Users/be/.gem/ruby/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel.rb:158:in `process_client'
/Users/be/.gem/ruby/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel.rb:285:in `run'
/Users/be/.gem/ruby/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel.rb:285:in `initialize'
/Users/be/.gem/ruby/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel.rb:285:in `new'
/Users/be/.gem/ruby/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel.rb:285:in `run'
/Users/be/.gem/ruby/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel.rb:268:in `initialize'
/Users/be/.gem/ruby/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel.rb:268:in `new'
/Users/be/.gem/ruby/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel.rb:268:in `run'
/Users/be/.gem/ruby/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel/configurator.rb:282:in `run'
/Users/be/.gem/ruby/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel/configurator.rb:281:in `each'
/Users/be/.gem/ruby/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel/configurator.rb:281:in `run'
/Users/be/.gem/ruby/1.8/gems/mongrel-1.1.5/bin/mongrel_rails:128:in `run'
/Users/be/.gem/ruby/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel/command.rb:212:in `run'
/Users/be/.gem/ruby/1.8/gems/mongrel-1.1.5/bin/mongrel_rails:281
/Users/be/.gem/ruby/1.8/bin/mongrel_rails:19:in `load'
/Users/be/.gem/ruby/1.8/bin/mongrel_rails:19

Then I added a "puts" in actionpack-2.3.8/lib/action_controller/cgi_process.rb:54:

  if headers.include?('Set-Cookie')
+   puts "Headers: #{headers.inspect}"
    headers['cookie'] = headers.delete('Set-Cookie').split("\n")
  end

And got:

Headers: {"Status"=>"200", "ETag"=>"\"5b5af20a92f1dbe92328005329d1753f\"", "Content-Type"=>"text/html; charset=utf-8", "X-Runtime"=>"2", "Content-Length"=>"3", "Cache-Control"=>"private, max-age=0, must-revalidate"}

There is no Set-Cookie.

Versions:

ruby 1.8.7 (2009-06-08 patchlevel 173) [universal-darwin10.0]
rack (1.1.0, 1.0.1, 1.0.0)

Reported by Edgars Beigarts · May 25th, 2010 @ 06:44 PM

State: resolved
Milestone: none
Assigned to: nobody
Importance: Low

Activity

  1. ...Paul
    ...Paul

    I'm getting a similar problem. script/server works fine, all good, but when I push out to my servers which use mongrel_cluster, when setting a cookie (such as after a login), I get the following:

    Error calling Dispatcher.dispatch #<NoMethodError: undefined method '[]' for nil:NilClass>
    .../mongrel/1.1.5/lib/mongrel/cgi.rb:108:in 'send_cookies'

    ruby 1.8.7 (2009-04-08 patchlevel 160) [amd-freebsd6]
    rack (1.1.0, 1.0.1)
    mongrel (1.1.5)
    mongrel_cluster (1.0.5)

    I did a rake rails:update, but did not note any changes resulting.

    May 25th, 2010 @ 11:52 PM

  2. Edgars Beigarts
    Edgars Beigarts

    In some apps I also had the same issue that Paul has.

    May 26th, 2010 @ 08:30 AM

  3. Evgeny
    Evgeny

    I have the same problem on hosting, even worse. When I create any app with a single scaffolded page the Mongrel returns a page as plain text. Here is the link to test page (won't be here for long): http://morningmare.com/users

    It seems like Mongrel crashes trying to send cookies. The response header has no Content-Type and it look like it's incomplete:
    curl 127.0.0.1:12002/users -I
    HTTP/1.1 200 OK
    Connection: close
    Date: Wed, 26 May 2010 09:24:44 GMT
    Content-Length: 0

    The Mongrel log shows the same error as Paul's:

    The error occurred while evaluating nil.[]>
    /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel/cgi.rb:108:in send_cookies' /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel/cgi.rb:136:inout' /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel/http_response.rb:65:in start'

    ruby 1.8.7, mongrel 1.1.5

    Any help would be appreciated!

    May 26th, 2010 @ 10:28 AM

  4. ...Paul
    ...Paul
    • Tag changed from 2.3.8, rack to 2.3.8, mongrel_cluster, rack

    Given that I know mongrel_cluster has fallen somewhat out of favor, I decided this might be the time to check out using Nginx with Passenger. Sure enough, the app works fine in that environment, so it's definitely some new incompatibility with mongrel_cluster 1.1.5...

    May 26th, 2010 @ 05:59 PM

  5. Edgars Beigarts
    Edgars Beigarts

    The problem has been solved in http://github.com/rack/rack/commit/f6f3c60938ea3b08f3292a2480e6753c...

    Rack (HEAD and 1.0):

    >> h = Rack::Utils::HeaderHash.new
    => {}
    >> h.include?('Set-Cookie')
    => false
    >> h['Set-Cookie']
    => nil
    >> h.include?('Set-Cookie')
    => false
    

    Rack (1.1):

    >> h = Rack::Utils::HeaderHash.new
    => {}
    >> h.include?('Set-Cookie')
    => false
    >> h['Set-Cookie']
    => nil
    >> h.include?('Set-Cookie')
    => true
    

    May 26th, 2010 @ 07:03 PM

  6. Edgars Beigarts
    Edgars Beigarts

    The problem has been solved in http://github.com/rack/rack/commit/f6f3c60938ea3b08f3292a2480e6753c...

    Rack (HEAD and 1.0):

    >> h = Rack::Utils::HeaderHash.new
    => {}
    >> h.include?('Set-Cookie')
    => false
    >> h['Set-Cookie']
    => nil
    >> h.include?('Set-Cookie')
    => false
    

    Rack (1.1):

    >> h = Rack::Utils::HeaderHash.new
    => {}
    >> h.include?('Set-Cookie')
    => false
    >> h['Set-Cookie']
    => nil
    >> h.include?('Set-Cookie')
    => true
    

    May 26th, 2010 @ 07:03 PM

  7. ...Paul
    ...Paul

    How does that solve the problem, given that I have rack 1.1.0? (Rails 2.3.8 will complain loudly if you don't have that revision...)

    May 26th, 2010 @ 07:11 PM

  8. Edgars Beigarts
    Edgars Beigarts

    Actually this solves only the first problem with "nil.split". :(

    May 26th, 2010 @ 07:58 PM

  9. Jonny_K
    Jonny_K
    • Tag changed from 2.3.8, mongrel_cluster, rack to 2.3.8, mongrel, mongrel_cluster, rack

    June 3rd, 2010 @ 03:21 PM

  10. demersus
    demersus

    I can confirm this issue is still happening. As of today. I just tried to deploy an app to a server with Rails 2.3.8 installed on it. It is running mongrel to serve the rails app.

    My log displays the exact same error as Edgar's first post.

    I keep getting a page with the following text: You are now being redirected
    Whenever the rails application sends a redirect. Instead of my browser redirecting.

    Also, if I try to submit a form it will kick back an error about an invalid authenticity token

    I was able to get my app deployed without error by downgrading to Rails 2.3.5

    June 4th, 2010 @ 11:11 PM

  11. Togg
    Togg

    Same issue. Works for script/server, but server as cluster (for apache balancer) fails with the exact same error as above.

    So is there any patch available yet?

    June 6th, 2010 @ 11:40 PM

  12. Mike C
    Mike C

    Same issue. Since nothing appears to have been done about it, I dug into it myself. Here is what I found:

    In file

    /var/lib/gems/1.8/gems/mongrel-1.1.5/lib/mongrel/cgi.rb

    method

    def send_cookies(to)

    First, this method is half-baked. It has a hash variable called options which may never have been called until now. It is getting called now because the "cookie" is always a string -- never an Array nor Hash (at least in my tests). I'm not sure what is correct for this, but after tinkering around a bunch, I got this to work:

        when String
          cookies = cookie.split.map { |a| a[-1..-1]==';'?a[0..-2]:a }
          cookies.each do |c|
            if c.split('=').count == 2
              to['Set-Cookie'] = c
            else
              to['Set-Cookie'] = c+'='
            end
          end
        else
          to['Set-Cookie'] = cookie.to_s
        end
    

    I believe this was the code it replaced (I didn't save my original file -- bad me):

        else
          to['Set-Cookie'] = options['cookie'].to_s
        end
    

    I don't know if it is necessary to remove the ';'. I did and it works. I'll accept an official patch, but I'm done messing with it for now.

    June 7th, 2010 @ 07:53 PM

  13. Scott Taylor
  14. bshand
    bshand

    The fix currently in fauna/mongrel does not resolve this issue.

    Mike C was on the right track, but was too-aggressively splitting apart cookies.

    I attach rails238_mongrel115_patch.diff which resolves this for me -- I've tested this in Windows XP SP3 with all permutations of Ruby 1.8.6 vs 1.8.7, Rails 2.3.5 vs 2.3.8, on our in-house application.

    As described by others, this issue is only apparent if you start mongrel before Rails, e.g. as a service or using
    $ mongrel_rails start

    Here are telnet logs that I used as a manual test case to verify my fix:

    Expected behaviour (Rails 2.3.5, Ruby 1.8.6 without fix):

    $ telnet localhost 3000
    GET /login HTTP/1.0


    HTTP/1.1 200 OK Connection: close Date: Thu, 10 Jun 2010 10:43:02 GMT Set-Cookie: BALANCEID=balancer127-0-0-1_b73a.x4000; path=/; expires=Thu, 10-Jun-2010 22:43:03 GMT Set-Cookie: _era_session_1968=e36001c1bc0008535135dc9bf5b931ac; path=/; HttpOnly Status: 200 ETag: "49b3e5defddedb74868b40692f24ede1" X-Runtime: 593 Cache-Control: no-store Server: Mongrel 1.1.5 Content-Type: text/html; charset=utf-8 Content-Length: 4399


    <!DOCTYPE HTML SYSTEM "http://:/dtd/era.dtd?1261589568">

    Actual behaviour (Rails 2.3.8, Ruby 1.8.6 without fix):

    $ telnet localhost 3000
    GET /login HTTP/1.0


    HTTP/1.1 200 OK Connection: close Date: Thu, 10 Jun 2010 10:41:04 GMT Content-Length: 4399


    <!DOCTYPE HTML SYSTEM "http://:/dtd/era.dtd?1261589568">

    Fixed behaviour (Rails 2.3.8, Ruby 1.8.6 with fix):

    $ telnet localhost 3000
    GET /login HTTP/1.0


    HTTP/1.1 200 OK Connection: close Date: Thu, 10 Jun 2010 10:36:54 GMT Set-Cookie: BALANCEID=balancer127-0-0-1_dd1a.x4000; path=/; expires=Thu, 10-Jun-2010 22:36:55 GMT Set-Cookie: _era_session_1468=a62eda630f1846d621f100470fda693d; path=/; HttpOnly Status: 200 X-Runtime: 31 ETag: "c0e26ca3e1ca46f354d4bd134e0ef1c8" Cache-Control: no-store Server: Mongrel 1.1.5 Content-Type: text/html; charset=utf-8 Content-Length: 4399


    <!DOCTYPE HTML SYSTEM "http://:/dtd/era.dtd?1261589568">

    June 10th, 2010 @ 12:08 PM

  15. Nat Brown
    Nat Brown

    for those of you still having issues, you do need to apply both the rack fix and the diff bshand posted.
    or if updating rack is tough, just make this change manually (sorry no diff) to gems/actionpack-2.3.8/lib/action_controller/cgi_process.rb at around :51.

            if headers.include?('Set-Cookie')
              headers['cookie'] = headers.delete('Set-Cookie').split("\n")
            end
    

    becomes

            if headers['Set-Cookie']
              headers['cookie'] = headers.delete('Set-Cookie').split("\n")
            end
    

    June 16th, 2010 @ 06:02 PM

  16. ...Paul
    ...Paul

    The simple fix natbro provided seems to have fixed the cookie issue, but redirects are still broken. Any redirect done results in page saying "You are being redirected" -- the redirect header, obviously not being transmitted in the response.

    June 23rd, 2010 @ 06:52 PM

  17. Matthew Denner
    Matthew Denner

    I don't know if this is relevant but in our environment (mongrel 1.1.5, rack 1.1.0, rails 2.3.8) the issue is actually with the 'header' method in lib/mongrel/cgi.rb. The Rack HeadersHash class appears to have different behaviour depending on whether you access a header directly or iterate over everything. In the 'header' method the latter is used, which causes @head['cookie'] to be a string, even though Rails sets an Array. By adding the following two lines:

     @head['cookie'] = options['cookie'] if options['cookie']
     options.delete('cookie')
    

    before:

      REMOVED_KEYS.each {|k| options.delete(k) }
    

    in the 'headers' method (about line 80-ish), we suddenly get not only the cookies but all of the headers our application sets, including the 'Location' header.

    June 25th, 2010 @ 12:15 PM

  18. Matthew Denner
    Matthew Denner

    A little bit more investigation reveals that something really is odd with options['cookie'] in the 'header' method as it's an array of arrays, and the elements are not quite split properly (with a leading '\n'). The simplest solution for our environment was to monkeypatch Mongrel using a Rails initializer:

    class Mongrel::CGIWrapper
      def header_with_rails_fix(options = 'text/html')
        @head['cookie'] = options.delete('cookie').flatten.map { |v| v.sub(/^\n/,'') } if options.class != String and options['cookie']
        header_without_rails_fix(options)
      end
      alias_method_chain(:header, :rails_fix)
    end if Rails.version == '2.3.8' and Gem.available?('mongrel', Gem::Requirement.new('~>1.1.5')) and self.class.const_defined?(:Mongrel)
    

    June 25th, 2010 @ 04:18 PM

  19. Andrew Selder
    Andrew Selder

    +1 for Matthew's monkey patch above.

    This actually looks like a bug in Mongrel, specifically their handling off cookies when @head['cookies'] is a string

    In lib/mongrel/cgi.rb, I believe there is a bug in send_cookies. When @head['cookies'] is an array or a hash, it iterates over the values and to_s's them, but when it's something else and tries to to_s the value of options['cookie'].

    The simple change of modifying line 110 of cgi.rb
    from

    to

    to['Set-Cookie] = cookie.to_s

    seems to fix this problem as well.

    June 28th, 2010 @ 07:07 PM

  20. Andrew Selder
    Andrew Selder

    Seems to have stripped the initial value of line 110 above

    to['Set-Cookie] = options['cookie'].to_s

    June 28th, 2010 @ 07:08 PM

  21. Luis Lavena
    Luis Lavena

    Hello,

    As commented in Mongrel issue tracker:

    http://github.com/fauna/mongrel/issues#issue/5

    Due the nature of mongrel_rails, it will be great get a fix applied that works with older versions of Rails.

    Up to now, no patch has been proposed for this.

    July 1st, 2010 @ 05:23 AM

  22. Ken Collins
    Ken Collins

    I took the throw it all at the wall approach and so far so good. I added this mongrel.rb to my config/initializers

    http://gist.github.com/471663

    July 11th, 2010 @ 05:43 PM

  23. bshand
    bshand

    Ken Collins' mongrel.rb initializer works for me -- on Windows with RubyGems 1.3.7 and Rails 1.8.6 (OneClick installer) / Rails 1.8.7 (RubyInstaller).

    It fails with RubyGems 1.3.5, unless I make the following addition patch to his mongrel.rb:

    $ diff mongrel.rb.orig mongrel.rb
    2c2
    < if Rails.version == '2.3.8' && Gem.available?('mongrel', Gem::Requirement.new('~>1.1.5')) && self.class.const_defined?(:Mongrel)
    ---
    > if Rails.version == '2.3.8' && Gem.available?('mongrel', '~>1.1.5') && self.class.const_defined?(:Mongrel)
    

    To verify that the fix works with multiple cookies, here's my telnet log, as above.

    $ telnet localhost 3000
    GET /login HTTP/1.0
    
    HTTP/1.1 200 OK
    Connection: close
    Date: Tue, 27 Jul 2010 09:04:59 GMT
    Set-Cookie: BALANCEID=balancer127-0-0-1_37fc.x4000; path=/; expires=Tue, 27-Jul-2010 21:05:00 GMT
    Set-Cookie: _era_session_4964=c0ee034da3546146cfa92021312c8892; path=/; HttpOnly
    Status: 200
    X-Runtime: 688
    ETag: "170e02320aab49443d3f7235ef06feb7"
    Cache-Control: no-store
    Server: Mongrel 1.1.5
    Content-Type: text/html; charset=utf-8
    Content-Length: 4262
    
    <!DOCTYPE html>
    

    July 27th, 2010 @ 10:11 AM

  24. timboisvert
    timboisvert

    Ken Collins' and bshand's solution worked for me. Thanks!

    July 30th, 2010 @ 04:14 PM

  25. amnesia7
    amnesia7

    I'm new to RoR and my app is running from a shared host so bear with me.

    I've used the code by Ken Collins in a /config/initializers/mongrel.rb file but I'm still getting the issue.

    I've tried changing the first line of the file as per bshand's suggestion but no joy either, so I put it back to Ken's version again.

    My app (based on RefineryCMS) works fine on my localhost. However, on the shared host the frontend of my app runs ok (http://spectrumplastics.net:12001/) but when I try to go to the login area (http://spectrumplastics.net:12001/refinery) I get a page using Firefox that says "You are being redirected." If I click the link to go to session/new then the login fails. I assume a cookie should be set somewhere along the way.

    Here's what I can gather:
    mongrel 1.1.5
    rails 2.3.8
    rubygems-update 1.3.7

    Any help would be much appreciated.

    Col

    August 2nd, 2010 @ 09:49 PM

  26. Damien White
    Damien White
    • Tag changed from 2.3.8, mongrel, mongrel_cluster, rack to 2, mongrel, mongrel_cluster, rack

    Ken,
    Thanks! Your solution worked great.

    -Damien

    August 3rd, 2010 @ 03:09 AM

  27. Damien White
    Damien White
    • Tag changed from 2, mongrel, mongrel_cluster, rack to 2.3.8, mongrel, mongrel_cluster, rack

    August 3rd, 2010 @ 03:12 AM

  28. etlund
    etlund

    Ken's mongrel.rb initializer works for me on my Engine Yard cloud apps.

    August 6th, 2010 @ 05:29 PM

  29. amnesia7
    amnesia7

    My app seems to be working now using Ken's code.

    For some reason I had to comment out the "if" statement:

    if Rails.version == '2.3.8' && Gem.available?('mongrel', Gem::Requirement.new('~>1.1.5')) && self.class.const_defined?(:Mongrel)

    and the associated "end" at the bottom.

    This line of code didn't seem to agree with the way my shared host is setup.

    August 6th, 2010 @ 06:12 PM

  30. Eduardo
    Eduardo
    • Tag changed from 2.3.8, mongrel, mongrel_cluster, rack to 2, mongrel, mongrel_cluster, rack

    Ken Collins' solution did no work for me. This error is being shown whenever a redirect_to is being executed: "ActionController::RoutingError (No route matches "/404.shtml" with {:method=>:get}):
    config/initializers/mongrel.rb:63:in dispatch_cgi'"

    RubyGems 1.3.7
    Rails 2.3.8
    mongrel_cluster 1.0.5
    mongrel (1.1.5 ruby java x86-mingw32 x86-mswin32-60)
    ruby 1.8.6 (2007-09-24 patchlevel 111) [x86_64-linux]
    rack 1.2.1

    August 19th, 2010 @ 04:25 AM

  31. Mike Bethany
    Mike Bethany

    The great guys that put all the hard work into coming up with these fixes sometimes forget a few of us are new to all this and they assume a lot of steps. So, for the other complete ruby newbies like myself you have to do this:

    1. Save this ruby code in your app to config/mongrel.rb: http://gist.github.com/471663
    2. In your config/environment.rb under the "require 'boot'" line file add:
      require File.join(File.dirname(File.expand_path(FILE)), 'mongrel')
    3. In that same file add this line in the Rails::initializer.run block:
      config.gem "mongrel"

    Note: I've been adding the File.expand_path because that seems to fix a lot of "require 'blah_blah_blah' not found" bugs.

    August 30th, 2010 @ 06:43 PM

  32. Mike Bethany
    Mike Bethany

    Major correction to my above statement:

    1. In your config/environment.rb at the very end of the file add:
      require File.join(File.dirname(File.expand_path(__FILE__)), 'mongrel')

    August 30th, 2010 @ 07:58 PM

  33. SUzB
    SUzB

    Thanks Mike! Your solution (August 30th, 2010 @ 06:43 PM and @ 07:58 PM) worked for me

    September 9th, 2010 @ 02:25 PM

  34. Lenart
    Lenart

    Mikes solution can by simplified by creating mongrel.rb in config/initializers since Rails loads all the files from that folder automatically.

    I also had to change first line of this patch according to bshand's comment.

    Great work guys!

    September 13th, 2010 @ 08:31 PM

  35. Steven Parkes
    Steven Parkes

    FWIW, this effects 2.3.9, too, but the mongrel.rb doesn't quite fit with 2.3.9 ...

    September 13th, 2010 @ 11:53 PM

  36. Mauro Morales
    Mauro Morales

    As Lenart mentioned Mike's and bshand's comments fixed it for me to. Thank you guys! I was getting mental.

    Also, like Eduardo I was getting a routing error but in my case it was my bad since I was redirecting the address without a slash / at the end of my redirection, adding it fixed the problem.

    October 7th, 2010 @ 06:24 AM

  37. David Trasbo
    David Trasbo
    • State changed from new to resolved
    • Importance changed from to Low

    Marking this as resolved for now.

    If this is still an issue, please note it here and I'll reopen. Patches with fixes/failing tests are much appreciated.

    October 7th, 2010 @ 09:08 PM

  38. Andrea Campi
    Andrea Campi
    • Tag changed from 2, mongrel, mongrel_cluster, rack to 2-3-stable, mongrel, mongrel_cluster, rack

    October 16th, 2010 @ 11:36 PM

  39. annabels
    annabels

    My app ran fine on my development laptop using webrick, but when I deployed it to the production server with mongrel_rails it developed two bugs:

    a. The content-type header of all the web pages it sent out was text/plain instead of text/html (which caused all pages to appear as black and white code in most browsers, and seemed to stop redirects working).

    b. I had to turn off the forgery prevention/authentication cookies.

    The Mike C, Lenart solution solved both issues (for Rails 2.3.8).

    Here is an idiot's guide - to save anyone having to trawl through all posts above to work it out:

    1. Download the file at http://gist.github.com/471663 and save to config/initializers/mongrel.rb in your application. (Then transfer to your production server obviously)

    2. Run mongrel_rails cluster::restart on your server.

    3. The first 2 steps solved both bugs for me - but if they don't make the change to mongrel.rb suggested by bshand above.

    Simple - only took a few minutes

    October 24th, 2010 @ 08:48 AM

  40. Jeff Kreeftmeijer
    Jeff Kreeftmeijer
    • Tag cleared.

    Automatic cleanup of spam.

    November 8th, 2010 @ 08:23 AM

  41. Jeff Kreeftmeijer
  42. zizilo
    zizilo

    For some reason I had to comment out the "if" statement:
    http://www.robesfr.com

    December 31st, 2010 @ 02:38 AM

  43. Woody
    Woody

    I was hesitant to monkey-patch w/o a better understanding of the problem. A summary of what I've found about the bug:

    The OP's problem (calling nil.split) won't be resolved until rails 2 depends on a version of rack that has either https://github.com/rack/rack/commit/f6f3c60938ea3b08f3292a2480e6753... or https://github.com/rack/rack/commit/b937c01bd16243276b24845efea4119... in it (v1.2 or master, respectively). Until then, monkey patching will be necessary to get mongrel_rails working due to it's use of Mongrel::CGIWrapper (script/server does not "require 'mongrel/rails'", which uses Mongrel's CGI wrapper, which in turn uses rack, which in version 1.1 has a bug that chokes on rails' cgi handling of mongrel's 'Set-Cookie'). OR, Rails' cgi handling could not use headers.include?, but that's a work-around.

    Also, FYI, the other bug mentioned here (calling nil.[]) is from a bug in Mongrel's CGI wrapper resolved 2 years ago, but still existing in Mongrel 1.1.5. Once the OP's bug is fixed, this case is hit because somewhere between Rails' mongrel-specific CGI code (see https://github.com/rails/rails/commit/b6e56efe) setting 'cookie' to an array and where mongrel looks at 'cookie' (https://github.com/fauna/mongrel/blob/rel_1-1-5/lib/mongrel/cgi.rb, 'send_cookie'), the 'cookie' header gets set back to a string, effectively nullifying that commit and triggering the old bug. I couldn't find where that happens, and won't be resolved until rails/rack/whatever doesn't un-array the 'cookie' header, or a new version of mongrel comes out.

    The gist: Mongrel's CGI doesn't work in Rails 2.3.8+ w/o monkey patching 2 separate (old) bugs, one for Rack, and the other for Mongrel.

    January 24th, 2011 @ 07:46 PM

  44. Roberto Aguilar
    Roberto Aguilar

    We spent a while researching this problem and ended up here to get the problem solved, but we have a quick note that hopefully will save others some time. When pulling the 'mongrel.rb' initializer file from Github, there are edits in the comments to address different versions of Rails as well as some incorrect syntax for a condition about the Mongrels which may give you an 'illformed requirement' error. A version of the gist that works for us can be found below. It has been tweaked to work for Rails versions ['2.3.8', '2.3.9', '2.3.10', '2.3.11'].

    Thanks.

    https://gist.github.com/826692

    February 14th, 2011 @ 10:40 PM

  45. af001
    af001

    私の中で、総合評価のとっても低いアバアバクロホリスタークロ銀座店。アバクロは大好きなんですけどね。一昨日の東京駅付近での打ち合わせの後、散歩がてら久々に行ってきました。

    May 5th, 2011 @ 02:52 AM

  46. learn italian online
    learn italian online

    brick, but when I deployed Ray Ban 2140 it to the production server with mongrel_rails it developed two Ray Ban 3025 bugs:a. The content-type header of all the web pages it sent out wa

    May 19th, 2011 @ 04:17 AM