title: Capistrano - can't deploy my database.yml
body: <p>When I try to deploy my app with capistrano, I'll get this error:   </p>
  
  <blockquote>
    <p>failed: "sh -c 'cp
    /var/www/my_app/releases/20120313115055/config/database.staging.yml
    /var/www/my_app/releases/20120313115055/config/database.yml'" on
    IP_ADDR</p>
  </blockquote>
  
  <p>My <strong>database.yml</strong> ie empty, <strong>database.staging.yml</strong>:</p>
  
  <pre><code>production:
    adapter: mysql2
    encoding: utf8
    reconnect: false
    database: my_db
    pool: 15
    username: my_user_name
    password: my_pass
    host: localhost
  </code></pre>
  
  <p>in the <strong>/confing/deploy</strong> are files "production" "staging"</p>
  
  <p>What am I missing here/where should I look for a failure? The credentials to database on the server should be right.</p>
  
  <p><strong>EDIT</strong> - here is my deploy</p>
  
  <pre><code>set :application, "my_app"
  set :repository, "https://IP_ADDR/svn/my_app"
  
  set :scm, :subversion
  set :scm_username, 'my_name'
  set :scm_password, 'my_pass'
  
  default_run_options[:pty] = true
  
  set :user, "my_name"
  set :domain, 'IP_ADDR'
  
  set :deploy_to, "/var/www/my_app"
  
  set :use_sudo, false
  set :deploy_via, :remote_cache
  #set :keep_releases, 1
  
  set :rails_env, 'production'
  
  role :web, domain
  role :app, domain
  role :db,   domain, :primary =&gt; true # This is where Rails migrations will run
  
  namespace :deploy do
  
      task :build_gems, :roles =&gt; :app do
          desc "Building gems"
          run "cd #{release_path} &amp;&amp; bundle install --deployment"
      end
  
      task :migrations do
          desc "Migrating database"
          run "cd #{release_path} &amp;&amp; rake db:migrate RAILS_ENV=production"
      end
  
      [:start, :stop].each do |t|
          desc "#{t} task is a no-op with passenger"
          task t, :roles =&gt; :app do ; end
      end
  
      desc "Restarting passenger with restart.txt"
      task :restart, :roles =&gt; :app, :except =&gt; { :no_release =&gt; true } do
          run "touch #{release_path}/tmp/restart.txt"
      end
  
      after "deploy:update_code", "deploy:build_gems", "db:copy_configuration", "config:copy", "deploy:migrations", "deploy:cleanup"
      after "deploy:update", "bluepill:copy_config", "bluepill:restart"
  end
  
  namespace :db do
      task :copy_configuration do
          run "cp #{release_path}/config/database.staging.yml #{release_path}/config/database.yml"
      end
  end
  
  namespace :config do
      task :copy do
          run "cp #{release_path}/config/config.staging.yml #{release_path}/config/config.yml"
      end
  end
  
  namespace :bluepill do
    desc "Restart bluepill process"
    task :restart, :roles =&gt; [:app] do
      run "#{release_path}/script/delayed_job stop"
      sudo "/etc/init.d/bluepill.sh restart"
    end
  
    #desc "Load bluepill configuration and start it"
    ##task :start, :roles =&gt; [:app] do
     # sudo "/etc/init.d/bluepill.sh start"
    #end
  
    desc "Prints bluepills monitored processes statuses"
    task :status, :roles =&gt; [:app] do
      sudo "bluepill status"
    end
  
    desc "Copy config"
    task :copy_config, :roles =&gt; [:app] do
      run "cp #{release_path}/config/bluepill/configuration.rb /srv/script/bluepill.rb"
    end
  end
  </code></pre>
  
  <p>The problem: </p>
  
  <pre><code>cp: cannot stat `/var/www/my_app/releases/20120313144907/config/database.staging.yml': No such file or directory
  </code></pre>