title: capistrano(3) deployment with use_sudo=true - undefined local variable or method default_run_options for main:Object
body: <p>I want to <code>cap production deploy:check</code>, but I got the error message <code>mkdir: cannot create directory /var/www: Permission denied</code>.
  I'm using Capistrano3 and Rails4.</p>
  
  <p>I think the sudo couldn't work in my case.</p>
  
  <p>deploy.rb</p>
  
  <pre><code>set :application, 'appname.com'
  set :repo_url, 'git@bitbucket.org:user/myapp.git'
  set :user, 'username'
  set :use_sudo, true
  set :branch, 'master'
  
  
  set :deploy_to, '/var/www/myapp'
  set :pty, true
  set :keep_releases, 5
  
  namespace :deploy do
  
   desc 'Restart application'
    task :restart do
     on roles(:app), in: :sequence, wait: 5 do
    end
   end
  
   after :restart, :clear_cache do
     on roles(:web), in: :groups, limit: 3, wait: 10 do
    end
   end
  
   after :finishing, 'deploy:cleanup'
  
  end
  </code></pre>
  
  <p>production.rb</p>
  
  <pre><code>set :stage, :production
  set :branch, 'master'
  role :all, %w{appname.com}
  server 'appname.com', user: 'username', port: 'port_number', roles: %w{web app db}, my_property: :my_value
  </code></pre>
  
  <p>I read these articles.</p>
  
  <p><a href="https://stackoverflow.com/questions/431925/capistrano-is-hanging-when-prompting-for-sudo-password-to-an-ubuntu-box">Capistrano is hanging when prompting for SUDO password to an Ubuntu box</a></p>
  
  <p><a href="https://stackoverflow.com/questions/1923572/capistrano-deployment-with-use-sudo-true-permissions-problem">capistrano deployment with use_sudo=true - permissions problem</a></p>
  
  <p>So I added <code>default_run_options[:pty] = true</code> to deploy.rb, but I got just <code>undefined local variable or method default_run_options for main:Object</code></p>
  
  <p>Thank you for your advice.</p>