title: Capistrano Deployment: a Task before `deploy:finalize_update` Is not Executed
body: <p>I'm using Capistrano v2.13.4 for deployment.</p>
  
  <p>A Capistrano task (<code>deploy:special_treats</code>) before <code>deploy:finalize_update</code> is not executed.</p>
  
  <p>The task <code>deploy:special_treats</code> does some preparation (setup the internet access) for <code>bundle:install</code>, otherwise, <code>bundle:install</code> will not be able to reach the Internet (<code>[out :: servername] Could not reach https://rubygems.org/</code></p>
  
  <p>In <code>config/deploy.rb</code></p>
  
  <p><code>
  before 'deploy:finalize_update', 'deploy:special_treats'
  </code></p>
  
  <p>and</p>
  
  <pre><code>namespace :deploy do
    task :special_treats do
      run "echo 'something special treats: setup the Internet access'"
    end
  end
  </code></pre>
  
  <p>The result for <code>cap deploy:update</code></p>
  
  <pre><code>$ cap deploy:update
    * executing `deploy:update'
   ** transaction: start
    * executing `deploy:update_code'
      executing locally: "svn info https://svnlinks --username username --password password --no-auth-cache  -rHEAD"
      command finished in 10336ms
    * getting (via export) revision 33268 to /tmp/20120927171608
      executing locally: svn export -q --username username --password password --no-auth-cache  -r33268 https://svnlinks /tmp/20120927171608
      command finished in 79314ms
    * processing exclusions...
    * Compressing /tmp/20120927171608 to /tmp/20120927171608.tar.gz
      executing locally: tar czf 20120927171608.tar.gz 20120927171608
      command finished in 1401ms
      servers: ["servername"]
   ** sftp upload /tmp/20120927171608.tar.gz -&gt; /tmp/20120927171608.tar.gz
      [servername] /tmp/20120927171608.tar.gz
      [servername] done
    * sftp upload complete
    * executing "cd /usr/website/rr/releases &amp;&amp; tar xzf /tmp/20120927171608.tar.gz &amp;&amp; rm /tmp/20120927171608.tar.gz"
      servers: ["servername"]
      [servername] executing command
      command finished in 774ms
    * executing `deploy:finalize_update'
      triggering before callbacks for `deploy:finalize_update'
    * executing `bundle:install'
    * executing "cd /usr/website/rr/releases/20120927171608 &amp;&amp; bundle install --gemfile /usr/website/rr/releases/20120927171608/Gemfile --path /usr/website/rr/shared/bundle --deployment --quiet --without development 
  
  test"
      servers: ["servername"]
      [servername] executing command
   ** [out :: servername] Could not reach https://rubygems.org/
      command finished in 1403ms
  *** [deploy:update_code] rolling back
    * executing "rm -rf /usr/website/rr/releases/20120927171608; true"
      servers: ["servername"]
      [servername] executing command
      command finished in 344ms
  failed: "rvm_path=$HOME/.rvm/ $HOME/.rvm/bin/rvm-shell '1.9.3-p194' -c 'cd /usr/website/rr/releases/20120927171608 &amp;&amp; bundle install --gemfile /usr/website/rr/releases/20120927171608/Gemfile --path 
  
  /usr/website/rr/shared/bundle --deployment --quiet --without development test'" on servername
  </code></pre>