RVM, Capistrano, Bundler woes
===

I cant run the task: `cap bundler:install_gems`

    Victors-MacBook-Air:clipper victorstan$ cap bundler:install_gems
      * executing `bundler:install_gems'
      * executing "ls -x /srv/www/clipper/releases"
        servers: ["victorstan.com"]
        [victorstan.com] executing command
        command finished in 2769ms
      * executing "/srv/www/clipper/releases/20120726030018 bundle install"
        servers: ["victorstan.com"]
        [victorstan.com] executing command
     ** [out :: victorstan.com] bash: /srv/www/clipper/releases/20120726030018: is a directory
        command finished in 1289ms
    failed: "rvm_path=$HOME/.rvm/ $HOME/.rvm/bin/rvm-shell '1.9.3' -c '/srv/www/clipper/releases/20120726030018 bundle install'" on victorstan.com

My deploy script is as follows:


    require 'rvm/capistrano'
    set :rvm_ruby_string, '1.9.3'
    
    require 'bundler/capistrano'
    
    set :application, "clipper"
    set :domain, "victorstan.com"
    set :repository,  "ssh://#{domain}/~/#{application}.git"
    
    set :scm, :git
    
    set :use_sudo,    true
    set :user, "victorstan"  # The server's user for deploys
    set :scm_username, "xxx"
    set :scm_passphrase, "xxx"  # The deploy user's password
    set :deploy_to,   "/srv/www/#{application}/"
    set :branch, "master"
    set :deploy_via, :remote_cache
    
    set :bundle_roles, "/srv/www/#{application}/current"
    
    default_run_options[:pty] = true
    
    role :web, domain                          # Your HTTP server, Apache/etc
    role :app, domain                          # This may be the same as your `Web` server
    role :db,  domain, :primary => true # This is where Rails migrations will run
    
    namespace :utils do
      desc "Enable Apache2 site"
      task :enable, :roles => :app do
        sudo "a2ensite #{application}"
        sudo "service apache2 graceful"
      end
    
      desc "Restart Apache2 Service: sudo service apache2 graceful"
      task :restartA2, :role => :app do
        sudo "service apache2 graceful"
      end
    end
    
    namespace :bundler do
      desc "Run: bundle install"
      task :install_gems, :role => :app do
        sudo run "#{current_release} bundle install"
      end
    
      desc "Run: bundle update"
      task :update_gems, :role => :app do
        sudo run "#{current_release} bundle update"
      end
    
      desc "Install Bundler"
      task :install_bundler, :role => :app do
        sudo "gem install bundler"
      end
    end
    
    # If you are using Passenger mod_rails uncomment this:
    namespace :deploy do
      task :start, :roles => :app do
        sudo "chown -R www-data:www-data #{current_release}/public"
        run "touch #{current_release}/tmp/restart.txt"
      end
    
      task :stop, :roles => :app do
        # Do nothing.
      end
    
      desc "Restart Application"
      task :restart, :roles => :app do
        run "touch #{current_release}/tmp/restart.txt"
      end
    
      desc "Migrate DB"
      task :migrate_db do
        run "cd #{current_path} && bundle exec rake db:migrate RAILS_ENV=production"
        run "touch #{current_path}/tmp/restart.txt"
      end
    
      task :cold do       # Overriding the default deploy:cold
        update
        load_schema       # My own step, replacing migrations.
        start
      end
    
      task :load_schema, :roles => :app do
        run "cd #{current_path}; RAILS_ENV=production rake db:schema:load"
      end
    end
    
    namespace :run_rake do
      desc "Run a task on a remote server: cap run_rake:invoke task="
      # run like: cap staging rake:invoke task=a_certain_task
      task :invoke, :roles => :app do
        run("cd #{deploy_to}/current; rake #{ENV['task']} RAILS_ENV=production")
      end
    end
    
    # after 'deploy:install_gems'

