3.1.0rc4 - Uninitialized constant Rack::Session::Abstract::SessionHash

Mod_passenger is failing with: uninitialized constant Rack::Session::Abstract::SessionHash. A few blog entries report that adding edge rack fixes this (on past pre-releases of rails 3.1), but doesn't seem to be working for me.

My Project Gemfile:

  source 'http://rubygems.org'

  gem 'rails', '3.1.0.rc4'

  # Supposedly, if you're running edge or pre-release rails,   # you have to include edge rack: http://ruby.ryanbigg.com/post/2105213615/uninitialized-constant   gem "rack", :git => "git://github.com/rack/rack.git"

  [snip]

This is a brand new project. We're using the latest passenger-common package on ubuntu paired with nginx.

I also tried loading rack 1.3.0 instead of edge rack, but that didn't make a difference. Neither did loading rack before rails.

Am getting this problem as well and tried what you've done, which also didn't work.

Have you managed to get this working yet?

No, unfortunately. I killed the project and started up a 3.0.8 stable one instead. It’s running fine on the same server.

Hello Mike,

Mod_passenger is failing with: uninitialized constant Rack::Session::Abstract::SessionHash.

The same issue has been driving mad all day today but I think I've finally cracked it.

Are you by any chance using Ubuntu with passenger installed as a package? If so, you might notice a rack 1.1 Ubuntu package by doing 'dpkg -l |grep rack'.

You might ALSO notice that rack 1.1 and passenger are installed in '/usr/lib/ruby/1.8', that is to say alongside Ruby's StdLib, and not in GEM_HOME '/usr/lib/ruby/gems/1.8/gems/' which is where they should be.

What happens is that passenger correctly assumes that your Rails app is a normal Rack app, and proceeds to load config.ru using rack 1.1 that the Ruby interpreter loads during its startup alongside StdLib.

Rubygems however, reports to bundler that rack 1.3 is indeed available in GEM_HOME, because it is, and as such bundler doesn't complain about the fact that 1.1 is loaded but 1.3 is reported as available.

Rails 3.1.rc4, BTW, requires rack 1.3, not master.

You can check which version of rack is reported in irb for the user you run passenger under...

  $ irb   > require 'rubygems'; require 'rack'; Rack.release   "1.3"

I bet it doesn't say "1.3" in your case.

DISCLAIMER: 95% of my conclusion is a result of my investigation and subsequent solution of my problem. The remaining 5%, about how bundler and Rubygems get their knickers in a twist because of the Ubuntu packaging 'guidelines', is an extrapolation. I didn't spend any time with the debugger stepping through Bundler and Rubygems source; I am not that patient.

Finally, I know this issue is not Rails-core specific, but my reply might help other people who come upon this thread...

-christos

This, kids, is why you never ever ever ever ever ever EVER rely on Ubuntu to not somehow fuck up your Ruby experience.

Please use RVM to install and manage your Ruby things, not Ubuntu's broken package manager.

http://ryanbigg.com/2010/12/ubuntu-ruby-rvm-rails-and-you/

Hey Christos,

Thanks for your time and effort. You’re absolutely right. I didn’t realize a packaged version of rack was installed on the server.

require ‘rubygems’; require ‘rack’; Rack.release

=> “1.1”

  • Mike

IMO never ever I would use RVM on a ubuntu server eveything should come through the ubuntu package manager (broken or not) including security updates.

and I run ruby on ubuntu happily without RVM after I found out how to avoid 'sudo' with bundler.

- Kristian

Please explain why you wouldn't use RVM on an Ubuntu server.

Package managers in general have proven unreliable for being in charge of any Ruby. They're often out of date and thus lack many of the released fixes (security or otherwise) and, as was mentioned before, they almost always have busted dependencies.

let's start somewhere:

on a ubuntu server I would setup a daily security update with APT - so I do not need to worry too much about security on the ubuntu site.

next you should get some idea when a security update needs a reboot, i.e. being on the mailing list of ubuntu security should help here.

ad RVM:

I just would not know how to use RVM with mod_passenger and alike.

normal rubygems which are needed by the application like rails, you bundle them anyways.

the remaining part is ruby itself and maybe the the rack gem which comes with passenger (to stay with the example of that thread). so then RVM is needed only for ruby and ONE gem.

RVM does NOT come via APT - and thus it is a package I need to monitor for "security" manually.

so in short for server level APT is responsible for a updated and secure system and for the application it is the basically "bundler" and the developer.

personally I use jruby a lot and run my application on jetty. there I have exactly the same distinction between server and application. in that case there is really no space for RVM: a war file bundles jruby itself or I install jruby on the servlet engine for the whole war container.

my point of view is also influenced by a setup of a school I helped two years back: * ldap posix authentication * nfs fileserver for the home directory

the only software which was allowed there came through APT because we needed to install that software on all ~50 workstations. the usual mantra I read over and over in the web "sudo gem install XZY" does not work here. even if the admin did it on one machine, the next day you used another machine where the gem was not install. bundler was annoying until I found a config where it install is it nicely like "gem install --user-install XYZ" in user space.

sreading ubuntu package system is broken - that is a strong statement. I would say ubuntu package system is not compatible with "rubygems package system" and therefore there are interferences in both directions.

hope that gives some inside into my state of mind :wink:

- Kristian

ad RVM: I just would not know how to use RVM with mod_passenger and alike.

That is simple. I can help if something is not clear.

Thanks to RVM you can have isolated Ruby versions and even gem sets inside the same Ruby version. For instance I have to use Ruby 1.8 for one old application and 1.9.2 for new ones. Because Passenger still does not work with many different Ruby interpreters (but it will!) I use proxy from Nginx to standalone Passenger 3 server which works in isolated environment (Ruby Enterprise + Rails 2.x gem set). I do not even waste any TCP port because Nginx can use unix proxy to standalone Passenger 3 server. For others Ruby/Rack applications I use Nginx with embed Passenger. Thanks to RVM I have isolated Ruby environments and access to the latest Ruby version. You cannot do this with Linux package system.

normal rubygems which are needed by the application like rails, you bundle them anyways.

This is only when you use just one Rails and Ruby version. What if your codebase grows and you would like to use newer Ruby? You can't, if you upgrade some old staff may stop working.

the remaining part is ruby itself and maybe the the rack gem which comes with passenger (to stay with the example of that thread). so then RVM is needed only for ruby and ONE gem.

As I said. RVM is not for one Ruby. It is for many ones. I sue RVM for Ruby 1.9.2, REE and JRuby. Three different and isolated environments. And Inside 1.9.2 I have two gem sets, one for standard Rails 3.x and another one for Rails 3.1 beta. And thanks to RVM I can be sure that I can switch from one to another without any mess in gems and dependencies.

RVM does NOT come via APT - and thus it is a package I need to monitor for "security" manually.

And this is good. Debian packages are (usually) old and permanently out of date. I want to access to the latest RVM and latest Rubies.

So, shortly, why RVM?

1) Isolated environments for any Ruby implementation (Ruby 1.8, 1.9, REE, JRuby, MagLev etc) 2) Isolated gem sets inside the same Ruby environment 3) The latest Ruby versions

Hey Christos,

Can you explain what we need to do to are application to get it working with rack 1.3? Mine is also saying 1.1 when I check the version of rack via irb.

Honestly, I always see Ubuntu Server as a joke. I imagine it like "Windows XP Server"... You should really be using Debian as a server, since Ubuntu is not reliable enough for a server anyway (I know by bad experience on Ubuntu servers in Locaweb)...

if I have the choice I would use debian as well.

but I had a few observations - heroku runs Stacks | Heroku Dev Center debian (or ubuntu) with one or two (ree-1.8.7 + mri-1.92).

for such a setup you just do not need RVM, the separation between those ruby's I get from ruby itself:

$HOME/.gem ├── jruby │ ├── 1.8 │ └── 1.9 ├── ruby    ├── 1.8    └── 1.9.2

so unless you use ruby-edge on a production server then ruby from the OS should do.

the actual problem with both debian and ubuntu is rubygems, just recently the one I had from ubuntu stopped working due to some updates on the rubygems.org server :frowning:

since RVM manage rubygems as well this is definitely a plus for it.

I wondered if you can really run mod_apache on apache with jruby - I appreciate any pointers to a howto for such a setup !!!!

anyways with jruby you put the java world into the round: how does RVM handles the different JVMs (from ibm, sun, openjdk, jrocket) and its different versions ?

- Kristian

PS just a thought: never is never right. always is always wrong

Hi Kristian,

First, I'm not sure if this is the correct list to discuss this issue...

Then, I would advise you to take a look at these instructions I used to set up Gitorious using Debian (or Ubuntu) packaged Ruby using Opscode Chef:

https://github.com/rosenfeld/gitorious-cookbooks

You should avoid installing rubygems from apt and use "tar zxf" instead for installing it. Than you can choose which Rubygems version you prefer to work with.

Hope that helps,

Rodrigo.

Basically you need to uninstall mod-passenger an librack-ruby using apt.

I did:

  apt-get remove --purge librack-ruby   apt-get remove --purge libapache2-mod-passenger

...and ignored any warnings about dependacies.

Then, I installed mod-passenger as a ruby gem:

  gem install passenger

Your milage may vary, but this is what got me back to a 'healthy' ubuntu installation.

-christos