:application variable not staying set

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

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!