How can I avoid permission denied errors when attempting to deploy a rails app with capistrano?
Posted
by
joshee
on Super User
See other posts from Super User
or by joshee
Published on 2012-03-26T22:11:26Z
Indexed on
2012/03/26
23:32 UTC
Read the original article
Hit count: 259
ruby-on-rails
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://[email protected]/~/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.
© Super User or respective owner