# RAILS\_ENV = "production" does not work

**URL:** <https://www.ruby-forum.com/t/rails-env-production-does-not-work/121976>\
**Category:** Deployment\
**Created:** [December 3, 2007, 3:37pm UTC](https://www.ruby-forum.com/t/rails-env-production-does-not-work/121976 "2007-12-03T15:37:17Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![subroutine](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/fbc32d/32.png) [@subroutine](https://www.ruby-forum.com/u/subroutine)\
**Post date:** [December 3, 2007, 3:37pm UTC](https://www.ruby-forum.com/t/rails-env-production-does-not-work/121976/1 "2007-12-03T15:37:17Z")

</div>

I recently deployed my application and it works fine except for one  
minor detail: I cannot change the environment from development to  
production.  
My environment.rb has the first line

#1  
ENV[“RAILS\_ENV”] = “production”

Opening the console and checking the environment with “ruby  
script/about” shows that I am in development mode, however.

Then I added this line

#2  
RAILS\_ENV = ENV[“RAILS\_ENV”]

But when I run “ruby script/about” with the second line #2 then I get an  
error message because the RAILS\_ENV constant has been initialized  
before, already. I am really puzzled why that is (where can it possibly  
have been set?).

Perhaps someone else had a similar problem and could point me in the  
right direction. Thanks a lot.

---

<div class="post-metadata">

**Author:** ![subroutine](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/fbc32d/32.png) [@subroutine](https://www.ruby-forum.com/u/subroutine)\
**Post date:** [December 3, 2007, 6:23pm UTC](https://www.ruby-forum.com/t/rails-env-production-does-not-work/121976/2 "2007-12-03T18:23:42Z")

</div>

try RAILS\_ENV=‘production’

ENV[“RAILS\_ENV”] has been deprecated.

-Matt

— [http://railsontherun.com](http://railsontherun.com)

On Dec 3, 6:37 am, Markus K. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![subroutine](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/fbc32d/32.png) [@subroutine](https://www.ruby-forum.com/u/subroutine)\
**Post date:** [December 3, 2007, 7:38pm UTC](https://www.ruby-forum.com/t/rails-env-production-does-not-work/121976/3 "2007-12-03T19:38:36Z")

</div>

Thanx for your reply, Matt.  
When I use RAILS\_ENV = “production” I get the error message:

[…] warning: already initialized constant RAILS\_ENV  
/var/lib/gems/1.8/gems/activesupport-1.4.4/lib/active\_support/dependencies.rb:263:in  
`load_missing_constant': uninitialized constant Rails::Info (NameError) from /var/lib/gems/1.8/gems/activesupport-1.4.4/lib/active_support/dependencies.rb:452:in`const\_missing’  
from /var/lib/gems/1.8/gems/rails-1.2.6/lib/commands/about.rb:2  
from /usr/lib/ruby/1.8/rubygems/custom\_require.rb:27:in  
`gem_original_require' from /usr/lib/ruby/1.8/rubygems/custom_require.rb:27:in`require’  
from script/about:5

I don’t really understand what’s going wrong here…

---

<div class="post-metadata">

**Author:** ![subroutine](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/fbc32d/32.png) [@subroutine](https://www.ruby-forum.com/u/subroutine)\
**Post date:** [December 3, 2007, 10:36pm UTC](https://www.ruby-forum.com/t/rails-env-production-does-not-work/121976/4 "2007-12-03T22:36:46Z")

</div>

When I use irb and type “RAILS\_ENV” I get the right environment, though.  
So, I suspect there is only a problem with the the about.rb file  
(probably something wrong with Rails::Info).

---

<div class="post-metadata">

**Author:** ![subroutine](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/fbc32d/32.png) [@subroutine](https://www.ruby-forum.com/u/subroutine)\
**Post date:** [December 3, 2007, 8:55pm UTC](https://www.ruby-forum.com/t/rails-env-production-does-not-work/121976/5 "2007-12-03T20:55:27Z")

</div>

I think my problem is similar. It works in development on my local  
machine but in production it gives me similar errors.  
Would love to know what to do to fix this.

Elle

On Dec 4, 5:38 am, Markus K. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![subroutine](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/fbc32d/32.png) [@subroutine](https://www.ruby-forum.com/u/subroutine)\
**Post date:** [June 7, 2008, 11:53pm UTC](https://www.ruby-forum.com/t/rails-env-production-does-not-work/121976/6 "2008-06-07T23:53:01Z")

</div>

On Dec 3 2007, 11:38 am, Markus K. \<ruby-forum-incom…@andreas-  
[s.net](http://s.net)\> wrote:

> ```
> from /usr/lib/ruby/1.8/rubygems/custom_require.rb:27:in
> 
> ```
> 
> `gem_original_require' from /usr/lib/ruby/1.8/rubygems/custom_require.rb:27:in `require’  
> from script/about:5
> 
> ## I don’t really understand what’s going wrong here…
> 
> Posted viahttp://www.ruby-forum.com/.

Same thing…dev ./script/about works, prod ./script/about does not.
