# :application variable not staying set

**URL:** <https://www.ruby-forum.com/t/application-variable-not-staying-set/109275>\
**Category:** Deployment\
**Created:** [July 13, 2007, 12:02am UTC](https://www.ruby-forum.com/t/application-variable-not-staying-set/109275 "2007-07-13T00:02:31Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![paulnva](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/e0b2c6/32.png) [@paulnva](https://www.ruby-forum.com/u/paulnva)\
**Post date:** [July 13, 2007, 12:02am UTC](https://www.ruby-forum.com/t/application-variable-not-staying-set/109275/1 "2007-07-13T00:02:31Z")

</div>

In trying to setup staging of various environments, I am having a  
problem setting the variables when other tasks are called.

In deploy.rb I have:

# for safety, set to development in case env is not set.

set :rails\_env, “development”  
set :application, “development”

desc “setup test settings”  
task :test do  
set :rails\_env, “test” # override :staging default  
set :application, “test”  
show  
end

task :show do  
puts “env = #{rails\_env}”  
puts “application = #{application}”  
end

when I run cap test update\_code I get the following:

- executing task test
- executing task show  
env = test  
application = test
- executing task update\_code
- querying latest revision…
- executing "if [[ ! -d /u/apps/development/releases/  
20070712213744 ]]; then\n svn co --no-auth-cache -q -  
r460 blah blah

env and application are set, but the application directory is still /  
u/  
apps/development/…

Is there a scope problem? is there an operator problem? This has me  
snowed! I know the answer is simple.

Thanks for help or a link for the solution…  
Cheers,  
Paul

---

<div class="post-metadata">

**Author:** ![paulnva](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/e0b2c6/32.png) [@paulnva](https://www.ruby-forum.com/u/paulnva)\
**Post date:** [July 17, 2007, 11:48am UTC](https://www.ruby-forum.com/t/application-variable-not-staying-set/109275/2 "2007-07-17T11:48:44Z")

</div>

Just in case someone is reading this, I got an answer on another forum  
and wanted to put here for completeness. and I dont’ know how to cross  
post this .

from Brian Smith  
"Try explicitly setting  
the :deploy\_to variable to lazily evaluate (lambda)… i.e.

set(:deploy\_to) { “/u/apps/#{application}” }

I think the problem is that :deploy\_to is being set based  
on :application BEFORE the task :test is being run. "

That seemed to do the trick!
