title: Sudo doesn't have access to shell commands when deploying with Capistrano
body: <p>I'm deploying my Rails 3 app using capistrano.</p>
  
  <p>I have on user (deploy) who's been added to sudoers. This is the user I'm deploying with.</p>
  
  <p>When I log on to the server as deploy I have access to all of the gem commands I need .ie: bundle, whenever etc.</p>
  
  <p>Capistrano seems to be running as sudo though, and when I try:</p>
  
  <pre><code>sudo whenever
  </code></pre>
  
  <p>I get </p>
  
  <pre><code>sudo: whenever: command not found
  </code></pre>
  
  <p>This means each time I try to deploy, it fails and rolls back.</p>
  
  <p>I've tried setting :use_sudo to false in my deploy.rb file but still no luck</p>
  
  <pre><code>set :user, "deploy"
  set :runner, user
  set :use_sudo, false
  </code></pre>
  
  <p>Any suggestions?</p>
  
  <p>Here's my complete deploy script in case there's anything in there I've missed:</p>
  
  <pre><code>require 'config/boot'
  require 'hoptoad_notifier/capistrano'
  require 'capistrano/ext/multistage'
  require "whenever/capistrano"
  # 
  set :whenever_command, "bundle exec whenever"
  
  set :application, "MYAPP"
  set :repository,  "git@github.com:myAccount/myRepos.git"
  
  # only keep 3 previous releases after cleanup
  set :keep_releases, 3
  
  set :scm, "git"
  set :scm_user, "me"
  set :branch, lambda {rails_env}
  set :deploy_to, lambda {"/var/www/#{application}/#{rails_env}"}
  
  
  default_run_options[:pty] = true
  
  role :web, "xxx.xxx.xxx.xxx"                          # Your HTTP server, Apache/etc
  role :app, "xxx.xxx.xxx.xxx"                          # This may be the same as your `Web` server
  role :db,  "xxx.xxx.xxx.xxx", :primary =&gt; true        # This is where Rails migrations will run
  
  set :user, "deploy"
  set :runner, user
  set :use_sudo, false
  
  ssh_options[:paranoid] = false 
  ssh_options[:port] = 22 
  
  namespace :deploy do
    task :start do ; end
    task :stop do ; end
    task :restart, :roles =&gt; :app do
      run " touch #{File.join(current_path,'tmp','restart.txt')}"
    end
  
  end
  
  namespace :bundle do
  
    desc "run bundle install"
    task :install do
      run "cd #{current_release} &amp;&amp; bundle install"
    end
  
  end
  
  namespace :tail do
  
    desc "Tail the current environment's log file"
    task :log, :roles =&gt; :app do
      stream "tail -f #{shared_path}/log/#{rails_env}.log"  
    end
  
    desc "Tail the new relic log file"
    task :new_relic, :roles =&gt; :app do
      stream "tail -f #{shared_path}/log/new_relic.log"  
    end
  
  end
  
  
  before "deploy:restart", "bundle:install"
  after "deploy:restart", "deploy:cleanup"
  after "deploy:restart", "whenever:update_crontab"
  </code></pre>