Q:

Capistrano failed - no current directory / bundle: not found / rolling back

Recently I moved one of my rails application to a newly configured EC2 ubuntu instance. Runs same ruby version as older server, apache with passenger. But I still couldn't get application deployed to the server with Capistrano. Still I have no idea about the error as well so I'm pasting my deploy logs here. Also here is my Capistrano recipe. Appreciate if someone can find the issue here. 
$ cap deploy:setup
    triggering start callbacks for `deploy:setup'
  * executing `uploads:register_dirs'
  * executing `deploy:setup'
  * executing "mkdir -p /home/ubuntu/webapps/myapp-name /home/ubuntu/webapps/myapp-name/releases /home/ubuntu/webapps/myapp-name/shared /home/ubuntu/webapps/myapp-name/shared/system /home/ubuntu/webapps/myapp-name/shared/log /home/ubuntu/webapps/myapp-name/shared/pids /home/ubuntu/webapps/myapp-name/shared/uploads"
    servers: ["ec2-184-73-xx-xxx.compute-1.amazonaws.com"]
    [ec2-184-73-xx-xxx.compute-1.amazonaws.com] executing command
    [ec2-184-73-xx-xxx.compute-1.amazonaws.com] sh -c 'mkdir -p /home/ubuntu/webapps/myapp-name /home/ubuntu/webapps/myapp-name/releases /home/ubuntu/webapps/myapp-name/shared /home/ubuntu/webapps/myapp-name/shared/system /home/ubuntu/webapps/myapp-name/shared/log /home/ubuntu/webapps/myapp-name/shared/pids /home/ubuntu/webapps/myapp-name/shared/uploads'
    command finished in 696ms
  * executing "chmod g+w /home/ubuntu/webapps/myapp-name /home/ubuntu/webapps/myapp-name/releases /home/ubuntu/webapps/myapp-name/shared /home/ubuntu/webapps/myapp-name/shared/system /home/ubuntu/webapps/myapp-name/shared/log /home/ubuntu/webapps/myapp-name/shared/pids /home/ubuntu/webapps/myapp-name/shared/uploads"
    servers: ["ec2-184-73-xx-xxx.compute-1.amazonaws.com"]
    [ec2-184-73-xx-xxx.compute-1.amazonaws.com] executing command
    [ec2-184-73-xx-xxx.compute-1.amazonaws.com] sh -c 'chmod g+w /home/ubuntu/webapps/myapp-name /home/ubuntu/webapps/myapp-name/releases /home/ubuntu/webapps/myapp-name/shared /home/ubuntu/webapps/myapp-name/shared/system /home/ubuntu/webapps/myapp-name/shared/log /home/ubuntu/webapps/myapp-name/shared/pids /home/ubuntu/webapps/myapp-name/shared/uploads'
    command finished in 205ms

Above doesn't create current directory for some reason but I can see the releases and shared directories. Plus inside shared dir I have another dir called uploads
$ cap deploy
    triggering start callbacks for `deploy'
  * executing `uploads:register_dirs'
  * executing `deploy'
  * executing `deploy:update'
 ** transaction: start
  * executing `deploy:update_code'
    executing locally: "git ls-remote . master"
    command finished in 5ms
  * getting (via checkout) revision a7e86283b743de666354349c56c66f80a35a6997 to /tmp/20120314153001
    executing locally: git clone -q . /tmp/20120314153001 && cd /tmp/20120314153001 && git checkout -q -b deploy a7e86283b743de666354349c56c66f80a35a6997
    command finished in 1879ms
    compressing /tmp/20120314153001 to /tmp/20120314153001.tar.gz
    executing locally: tar czf 20120314153001.tar.gz 20120314153001
    command finished in 4323ms
    servers: ["ec2-184-73-xx-xxx.compute-1.amazonaws.com"]
 ** sftp upload /tmp/20120314153001.tar.gz -> /tmp/20120314153001.tar.gz
    [ec2-184-73-xx-xxx.compute-1.amazonaws.com] sftp upload /tmp/20120314153001.tar.gz -> /tmp/20120314153001.tar.gz
    [ec2-184-73-xx-xxx.compute-1.amazonaws.com] sftp upload /tmp/20120314153001.tar.gz -> /tmp/20120314153001.tar.gz done
  * sftp upload complete
  * executing "cd /home/ubuntu/webapps/myapp-name/releases && tar xzf /tmp/20120314153001.tar.gz && rm /tmp/20120314153001.tar.gz"
    servers: ["ec2-184-73-xx-xxx.compute-1.amazonaws.com"]
    [ec2-184-73-xx-xxx.compute-1.amazonaws.com] executing command
    [ec2-184-73-xx-xxx.compute-1.amazonaws.com] sh -c 'cd /home/ubuntu/webapps/myapp-name/releases && tar xzf /tmp/20120314153001.tar.gz && rm /tmp/20120314153001.tar.gz'
    command finished in 2353ms
  * executing `deploy:finalize_update'
  * executing "chmod -R g+w /home/ubuntu/webapps/myapp-name/releases/20120314153001"
    servers: ["ec2-184-73-xx-xxx.compute-1.amazonaws.com"]
    [ec2-184-73-xx-xxx.compute-1.amazonaws.com] executing command
    [ec2-184-73-xx-xxx.compute-1.amazonaws.com] sh -c 'chmod -R g+w /home/ubuntu/webapps/myapp-name/releases/20120314153001'
    command finished in 294ms
  * executing "rm -rf /home/ubuntu/webapps/myapp-name/releases/20120314153001/log /home/ubuntu/webapps/myapp-name/releases/20120314153001/public/system /home/ubuntu/webapps/myapp-name/releases/20120314153001/tmp/pids &&\\\n      mkdir -p /home/ubuntu/webapps/myapp-name/releases/20120314153001/public &&\\\n      mkdir -p /home/ubuntu/webapps/myapp-name/releases/20120314153001/tmp"
    servers: ["ec2-184-73-xx-xxx.compute-1.amazonaws.com"]
    [ec2-184-73-xx-xxx.compute-1.amazonaws.com] executing command
    [ec2-184-73-xx-xxx.compute-1.amazonaws.com] sh -c 'rm -rf /home/ubuntu/webapps/myapp-name/releases/20120314153001/log /home/ubuntu/webapps/myapp-name/releases/20120314153001/public/system /home/ubuntu/webapps/myapp-name/releases/20120314153001/tmp/pids &&\
    [ec2-184-73-xx-xxx.compute-1.amazonaws.com] mkdir -p /home/ubuntu/webapps/myapp-name/releases/20120314153001/public &&\
    [ec2-184-73-xx-xxx.compute-1.amazonaws.com] mkdir -p /home/ubuntu/webapps/myapp-name/releases/20120314153001/tmp'
    command finished in 211ms
  * executing "ln -s /home/ubuntu/webapps/myapp-name/shared/system /home/ubuntu/webapps/myapp-name/releases/20120314153001/public/system"
    servers: ["ec2-184-73-xx-xxx.compute-1.amazonaws.com"]
    [ec2-184-73-xx-xxx.compute-1.amazonaws.com] executing command
    [ec2-184-73-xx-xxx.compute-1.amazonaws.com] sh -c 'ln -s /home/ubuntu/webapps/myapp-name/shared/system /home/ubuntu/webapps/myapp-name/releases/20120314153001/public/system'
    command finished in 193ms
  * executing "ln -s /home/ubuntu/webapps/myapp-name/shared/log /home/ubuntu/webapps/myapp-name/releases/20120314153001/log"
    servers: ["ec2-184-73-xx-xxx.compute-1.amazonaws.com"]
    [ec2-184-73-xx-xxx.compute-1.amazonaws.com] executing command
    [ec2-184-73-xx-xxx.compute-1.amazonaws.com] sh -c 'ln -s /home/ubuntu/webapps/myapp-name/shared/log /home/ubuntu/webapps/myapp-name/releases/20120314153001/log'
    command finished in 189ms
  * executing "ln -s /home/ubuntu/webapps/myapp-name/shared/pids /home/ubuntu/webapps/myapp-name/releases/20120314153001/tmp/pids"
    servers: ["ec2-184-73-xx-xxx.compute-1.amazonaws.com"]
    [ec2-184-73-xx-xxx.compute-1.amazonaws.com] executing command
    [ec2-184-73-xx-xxx.compute-1.amazonaws.com] sh -c 'ln -s /home/ubuntu/webapps/myapp-name/shared/pids /home/ubuntu/webapps/myapp-name/releases/20120314153001/tmp/pids'
    command finished in 191ms
  * executing "ln -s /home/ubuntu/webapps/myapp-name/shared/uploads /home/ubuntu/webapps/myapp-name/releases/20120314153001/uploads"
    servers: ["ec2-184-73-xx-xxx.compute-1.amazonaws.com"]
    [ec2-184-73-xx-xxx.compute-1.amazonaws.com] executing command
    [ec2-184-73-xx-xxx.compute-1.amazonaws.com] sh -c 'ln -s /home/ubuntu/webapps/myapp-name/shared/uploads /home/ubuntu/webapps/myapp-name/releases/20120314153001/uploads'
    command finished in 191ms
  * executing "find /home/ubuntu/webapps/myapp-name/releases/20120314153001/public/images /home/ubuntu/webapps/myapp-name/releases/20120314153001/public/stylesheets /home/ubuntu/webapps/myapp-name/releases/20120314153001/public/javascripts -exec touch -t 201203141535.01 {} ';'; true"
    servers: ["ec2-184-73-xx-xxx.compute-1.amazonaws.com"]
    [ec2-184-73-xx-xxx.compute-1.amazonaws.com] executing command
    [ec2-184-73-xx-xxx.compute-1.amazonaws.com] env TZ=UTC sh -c 'find /home/ubuntu/webapps/myapp-name/releases/20120314153001/public/images /home/ubuntu/webapps/myapp-name/releases/20120314153001/public/stylesheets /home/ubuntu/webapps/myapp-name/releases/20120314153001/public/javascripts -exec touch -t 201203141535.01 {} '\'';'\''; true'
    command finished in 2057ms
    triggering after callbacks for `deploy:finalize_update'
  * executing `uploads:symlink'
  * executing "rm -rf /home/ubuntu/webapps/myapp-name/releases/20120314153001/public/uploads"
    servers: ["ec2-184-73-xx-xxx.compute-1.amazonaws.com"]
    [ec2-184-73-xx-xxx.compute-1.amazonaws.com] executing command
    [ec2-184-73-xx-xxx.compute-1.amazonaws.com] sh -c 'rm -rf /home/ubuntu/webapps/myapp-name/releases/20120314153001/public/uploads'
    command finished in 192ms
  * executing "ln -nfs /home/ubuntu/webapps/myapp-name/shared/uploads /home/ubuntu/webapps/myapp-name/releases/20120314153001/public/uploads"
    servers: ["ec2-184-73-xx-xxx.compute-1.amazonaws.com"]
    [ec2-184-73-xx-xxx.compute-1.amazonaws.com] executing command
    [ec2-184-73-xx-xxx.compute-1.amazonaws.com] sh -c 'ln -nfs /home/ubuntu/webapps/myapp-name/shared/uploads /home/ubuntu/webapps/myapp-name/releases/20120314153001/public/uploads'
    command finished in 204ms
  * executing `bundle:install'
  * executing "ls -x /home/ubuntu/webapps/myapp-name/releases"
    servers: ["ec2-184-73-xx-xxx.compute-1.amazonaws.com"]
    [ec2-184-73-xx-xxx.compute-1.amazonaws.com] executing command
    [ec2-184-73-xx-xxx.compute-1.amazonaws.com] sh -c 'ls -x /home/ubuntu/webapps/myapp-name/releases'
    command finished in 188ms
  * executing "cd /home/ubuntu/webapps/myapp-name/releases/20120314153001 && bundle install --gemfile /home/ubuntu/webapps/myapp-name/releases/20120314153001/Gemfile --path /home/ubuntu/webapps/myapp-name/shared/bundle --deployment --quiet --without development test"
    servers: ["ec2-184-73-xx-xxx.compute-1.amazonaws.com"]
    [ec2-184-73-xx-xxx.compute-1.amazonaws.com] executing command
    [ec2-184-73-xx-xxx.compute-1.amazonaws.com] sh -c 'cd /home/ubuntu/webapps/myapp-name/releases/20120314153001 && bundle install --gemfile /home/ubuntu/webapps/myapp-name/releases/20120314153001/Gemfile --path /home/ubuntu/webapps/myapp-name/shared/bundle --deployment --quiet --without development test'
*** [err :: ec2-184-73-xx-xxx.compute-1.amazonaws.com] sh:
*** [err :: ec2-184-73-xx-xxx.compute-1.amazonaws.com] bundle: not found
*** [err :: ec2-184-73-xx-xxx.compute-1.amazonaws.com] 
    command finished in 189ms
*** [deploy:update_code] rolling back
  * executing "rm -rf /home/ubuntu/webapps/myapp-name/releases/20120314153001; true"
    servers: ["ec2-184-73-xx-xxx.compute-1.amazonaws.com"]
    [ec2-184-73-xx-xxx.compute-1.amazonaws.com] executing command
    [ec2-184-73-xx-xxx.compute-1.amazonaws.com] sh -c 'rm -rf /home/ubuntu/webapps/myapp-name/releases/20120314153001; true'
    command finished in 435ms
failed: "sh -c 'cd /home/ubuntu/webapps/myapp-name/releases/20120314153001 && bundle install --gemfile /home/ubuntu/webapps/myapp-name/releases/20120314153001/Gemfile --path /home/ubuntu/webapps/myapp-name/shared/bundle --deployment --quiet --without development test'" on ec2-184-73-xx-xxx.compute-1.amazonaws.com

A:

In short it looks like the bundle command isn't being found on the server.
You can confirm it is installed by SSH'ing into the server as 'ubuntu' (the user specified in the deploy file) and try running bundle.  If you get a command not found error, then bundler might not be installed or the 'ubuntu' user does not have permissions.
If the above command does work, then your environment variables might no be getting loaded when cap tried to execute its commands.  I had to specify the following environment variables in the deploy script:
default_environment['PATH'] = '/usr/local/lib/ruby/gems/1.9.1/bin:$PATH'
default_environment['GEM_PATH']= '/usr/local/lib/ruby/gems/1.9.1'

Obviously, adjust the paths to suit your server's configuration.
I hope this helps!

