Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Total noob here. I'm attempting to deploy an app through Capistrano. I'm getting relentless permission denied errors when I attempt to run cap deploy:update. Seemingly at least some of these errors are due to missing directories that trigger a "Permission Denied" error. (I'm doing setup on root just temporarily.)

set :user, 'root'
set :domain, 'domainname.com'
set :application, 'appname'
# adjust if you are using RVM, remove if you are not
$:.unshift(File.expand_path('./lib', ENV['rvm_path']))
require "rvm/capistrano"
set :rvm_ruby_string, '1.9.2'
# file paths
set :repository, "ssh://root@domain.com/~/git/appname.git"
set :deploy_to, "/var/rails/appname"
# distribute your applications across servers (the instructions below put them
# all on the same server, defined above as 'domain', adjust as necessary)
role :app, domain 
role :web, domain
role :db, domain, :primary => true
set :deploy_via, :remote_cache
set :scm, 'git'
set :branch, 'master'
set :scm_verbose, true
set :use_sudo, false
set :rails_env, :production
namespace :deploy do
desc "cause Passenger to initiate a restart"
task :restart do
run "touch #{current_path}/tmp/restart.txt"
end
desc "reload the database with seed data"
task :seed do
run "cd #{current_path}; rake db:seed RAILS_ENV=#{rails_env}"
end
end
after "deploy:update_code", :bundle_install
desc "install the necessary prerequisites"
task :bundle_install, :roles => :app do
run "cd #{release_path} && bundle install"
end

Here's my result:

** [domainname.com :: out] Cloning into '/var/rails/appname/shared/cached-copy'...
** [domainname.com :: err] Permission denied, please try again.
** [domainname.com :: err] Permission denied, please try again.
** [domainname.com :: err] Permission denied (publickey,gssapi-with-mic,password).
** [domainname.com :: err] fatal: The remote end hung up unexpectedly

I'm able to ssh without a password, so not sure about that publickey error.

By the way, if I run cap deploy:update without set :deploy_via, :remote_cache, here's my result:

 ** [domainname.com :: out] Cloning into '/var/rails/appname/releases/20120326204237'...
 ** [domainname.com :: err] Permission denied, please try again.
 ** [domainname.com :: err] Permission denied, please try again.
 ** [domainname.com :: err] Permission denied (publickey,gssapi-with-mic,password).
 ** [domainname.com :: err] fatal: The remote end hung up unexpectedly
command finished

Thanks a lot for your help with this.

UPDATE Adding ssh_options[:forward_agent] = true to deploy.rb seemed to improve things somewhat.

share|improve this question
1  
Please don't post the answer in the question or add "Solved" to the title. Post the solution as an answer. If you can't answer yet post a comment. –  ChrisF Mar 27 '12 at 12:48
add comment

1 Answer

You can add

set :admin_runner, "my_apps_username"

in config/deploy.rb. Alternatively, you can override the deploy:setup task like this:

namespace :deploy do
  task :setup, :except => { :no_release => true } do
    dirs = [deploy_to, releases_path, shared_path]
    dirs += shared_children.map { |d| File.join(shared_path, d.split('/').last) }
    run "mkdir -p #{dirs.join(' ')}"
    run "chmod g+w #{dirs.join(' ')}" if fetch(:group_writable, true)
  end
end
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.