Rails 3 "RAILS_ENV not defined by config/boot" error

Eric Wong normalperson at yhbt.net
Thu Feb 18 18:36:32 EST 2010

Eric Wong <normalperson at yhbt.net> wrote:
> John Wulff <johnwulff at gmail.com> wrote:
> > I'm running unicorn and unicorn-rails 0.96.1 and the latest Rails 3
> > beta gem.  Firing up unicorn_rails spews "RAILS_ENV not defined by
> > config/boot".  I know this is likely a result of RAILS_ROOT being
> > deprecated in Rails 3 but I can't seem to config my way around it.
> > I'm sure other people must have run into this before.  Is there a
> > quick fix?
> Hi John,
> I haven't had a chance to look at Rails 3 yet, but you can probably try
> just using a plain config.ru with "unicorn" (not "unicorn_rails")

I've been planning on some large-ish changes in Unicorn 0.97.x to
bin/{unicorn,unicorn_rails} to make maintenance easier and fix
a few minor issues with the existing code.

Would the following change be enough to work with Rails 3

diff --git a/bin/unicorn_rails b/bin/unicorn_rails
index b1458fc..4441c34 100755
--- a/bin/unicorn_rails
+++ b/bin/unicorn_rails
@@ -128,8 +128,6 @@ app = lambda do ||
   rescue LoadError => err
     abort "#$0 must be run inside RAILS_ROOT: #{err.inspect}"
-  defined?(::RAILS_ROOT) or abort "RAILS_ROOT not defined by config/boot"
-  defined?(::RAILS_ENV) or abort "RAILS_ENV not defined by config/boot"
   defined?(::Rails::VERSION::STRING) or
     abort "Rails::VERSION::STRING not defined by config/boot"

(I'll remember to test when I fix a few other things elsewhere)

Eric Wong

More information about the mongrel-unicorn mailing list