0

I'm trying to deploy a Rails app using Capistrano. I followed the tutorial How to Deploy a Rails 4 App with Git and Capistrano. However, when I run cap production deploy:check, it gives me this error:

INFO[349a4b8d] Running /usr/bin/env mkdir -p /tmp/app_name/ on xxx.xx.xxx.xxx
DEBUG[349a4b8d] Command: /usr/bin/env mkdir -p /tmp/app_name/
INFO[cd49f0ac] Running /usr/bin/env mkdir -p /tmp/app_name/ on example.com
DEBUG[cd49f0ac] Command: /usr/bin/env mkdir -p /tmp/app_name/
cap aborted!
SSHKit::Runner::ExecuteError: Exception while executing on host xxx.xx.xxx.xxx: Authentication failed for user @xxx.xx.xxx.xxx

My first thought was that I did need to use sudo, but mkdir shouldn't need sudo in /tmp/. My second thought was that it needs a password for ssh, but I use public keys to ssh between my development computer and the server. Any ideas?

Here is my config/deploy.rb:

lock '3.2.1'

set :application, 'app_name'

set :repo_url, '[email protected]:remote/app_name.git'
set :scm, :git

set :user, 'deploy'
set :use_sudo, false

set :stage, :production

set :rails_env, 'production'
set :deploy_via, :remote_cache

set :keep_releases, 5

set :ssh_options, { forward_agent: true }

set :pty, true

server 'xxx.xx.xxx.xxx', roles: [:app, :web, :db], primary: true

namespace :deploy do

  desc 'Restart application'
  task :restart do
    on roles(:app), in: :sequence, wait: 5 do
      # Your restart mechanism here, for example:
      # execute :touch, release_path.join('tmp/restart.txt')
    end
  end

  after :publishing, :restart

  after :restart, :clear_cache do
    on roles(:web), in: :groups, limit: 3, wait: 10 do
      # Here we can do anything such as:
      # within release_path do
      #   execute :rake, 'cache:clear'
      # end
    end
  end

end

I'm using Ruby 2.1.0, Rails 4.1.4, and Capistrano 3.2.1.

1 Answer 1

2

I found a few things wrong with my setup. First, I forgot to fill in any information in config/deploy/production.rb. In this same file, I also added the line set :password, ask('Server password:', nil).

Second, the reason why I had this error is because of permission issues. Apparently this user didn't have permission to modify /var/www. To change that, I simply entered sudo chown deploy:deployers /var/www. Also, I needed to include login credentials for GitHub on the server.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.