(With apologies to Penny Arcade)
I’m probably the last person on earth to realise this, but the
environment variable (and the
-E option to
rackup) isn’t intended for
consumption by anything other than Rack itself.
If you want to indicate what sort of environment your application should run
in, you’re going to have to do it via some other means.
Why is this? Because the interpretation that Rack applies to the value of
RACK_ENV that you set makes no sense whatsoever outside of Rack. Valid
options are “
deployment”, and “
none”. If you follow
the usual Rails convention of naming your environments “
test”, and “
production” (and maybe “
staging” if you’re feeling
adventurous), then in any environment other than “
not going to be telling Rack anything it understands.
As I said, I may be the last person on earth to have worked this out, but I
doubt it. There are plenty of bug reports and “WTF?” blog posts and Stack
Overflow questions that appear to stem from people misunderstanding the
purpose of RACK_ENV. Sadly, the Rack documentation is very quiet on the
whole topic, and the only place that mentions how the environment is
interpreted is in the comments for
Rack::Server.new – and that doesn’t
tie that environment to the
-E option or
At any rate, the take away is simple: unless you want Rack to pre-configure
a bundle of middleware for you,
rackup -E is not the
configuration variable you’re looking for. Use something else to tell your
app how it’s supposed to work.