I had the same issue while trying to deploy a production app. I'm using rbenv to manage my ruby environments unicorn installed by default into rbenv. The gem dependencies listed in the Gemfile are being installed by bundler. It happens this was causing the issue.
The workaround I did was to uninstall unicorn from rbenv's environment and install it through the Gemfile. After all, I think this approach is more clean and straightforward.
If you are using RVM, the issue happens if you define a gem in the global environment that depends on rack the same way unicorn does and then define a per-project gemset. I think this is because of the dependencies of rails 3.1 (I'm not sure though). The solution is to uninstall unicorn (or the gem that installs rack 1.4.1) from global gemset and install it in a per-project gemset.
If you are using bundler and RVM you have two options:
- create a gemset with rails and the gem that installs rack 1.4.1 (best suitable for dev workstations)
- put the gem that depends on rack 1.4.1 in the Gemfile and let the bundler to the magic.