I'm trying to deploy code with Capistrano 3 to Ubuntu server from GIT repository, but I'm getting this error.
==========================================================================
Here is my Gemfile.
gem 'capistrano', '~> 3.1.0'
#//Use unicorn as the app server
gem 'unicorn'
#// Use Capistrano for deployment
group :development do
gem 'capistrano-rails'
gem 'capistrano-bundler'
gem 'capistrano-rbenv', "~> 2.0"
end
source 'https://rubygems.org'
========================================================================== #deploy.rb
lock '3.1.0'
#// Define the name of the application
set :application, 'my_app'
#// Define where can Capistrano access the source repository
#// set :repo_url, 'https://github.com/[user name]/[application name].git'
set :scm, :git
set :repo_url, '[email protected]:jaipratik/rw.git'
set :use_sudo, true
set :log_level, :debug
#// Define where to put your application code
set :deploy_to, "/var/www/my_app"
set :pty, true
set :format, :pretty
========================================================================== #// production.rb
role :app, %w{ubuntu@{IP/Host}}
server '{IP/Host}', user: 'ubuntu', roles: %w{web app}
set :ssh_options, {
keys: %w(/Users/jay/.ssh/id_rsa),
forward_agent: false,
user: 'user'
# auth_methods: %w(password)
}
========================================================================== result for $ bundle exec cap production deploy --trace
** Invoke production (first_time)
** Execute production
** Invoke load:defaults (first_time)
** Execute load:defaults
** Invoke deploy (first_time)
** Execute deploy
** Invoke deploy:starting (first_time)
** Execute deploy:starting
** Invoke deploy:check (first_time)
** Execute deploy:check
** Invoke git:check (first_time)
** Invoke git:wrapper (first_time)
** Execute git:wrapper
INFO[f8299d4f] Running /usr/bin/env mkdir -p /tmp/my_app/ on {IP/Host}
DEBUG[f8299d4f] Command: /usr/bin/env mkdir -p /tmp/my_app/
INFO[f8299d4f] Finished in 0.723 seconds with exit status 0 (successful).
DEBUGUploading /tmp/my_app/git-ssh.sh 0.0%
INFOUploading /tmp/my_app/git-ssh.sh 100.0%
INFO[b509dfb7] Running /usr/bin/env chmod +x /tmp/my_app/git-ssh.sh on {IP/Host}
DEBUG[b509dfb7] Command: /usr/bin/env chmod +x /tmp/my_app/git-ssh.sh
INFO[b509dfb7] Finished in 0.084 seconds with exit status 0 (successful).
** Execute git:check
DEBUG[9646aea0] Running /usr/bin/env git ls-remote [email protected]:jaipratik/rw.git on {IP/Host}
DEBUG[9646aea0] Command: ( GIT_ASKPASS=/bin/echo GIT_SSH=/tmp/my_app/git-ssh.sh /usr/bin/env git ls-remote [email protected]:jaipratik/rw.git )
DEBUG[9646aea0] c452c845bb80f72d3023557d2ea8f776950c659f
DEBUG[9646aea0]
DEBUG[9646aea0] HEAD
DEBUG[9646aea0]
DEBUG[9646aea0] c452c845bb80f72d3023557d2ea8f776950c659f
DEBUG[9646aea0]
DEBUG[9646aea0] refs/heads/master
DEBUG[9646aea0]
DEBUG[9646aea0] Finished in 0.940 seconds with exit status 0 (successful).
** Invoke deploy:check:directories (first_time)
** Execute deploy:check:directories
INFO[fa4b1f56] Running /usr/bin/env mkdir -pv /var/www/my_app/shared /var/www/my_app/releases on {IP/Host}
DEBUG[fa4b1f56] Command: /usr/bin/env mkdir -pv /var/www/my_app/shared /var/www/my_app/releases
INFO[fa4b1f56] Finished in 0.086 seconds with exit status 0 (successful).
** Invoke deploy:check:linked_dirs (first_time)
** Execute deploy:check:linked_dirs
** Invoke deploy:check:make_linked_dirs (first_time)
** Execute deploy:check:make_linked_dirs
** Invoke deploy:check:linked_files (first_time)
** Execute deploy:check:linked_files
** Invoke deploy:started (first_time)
** Execute deploy:started
** Invoke deploy:updating (first_time)
** Invoke deploy:new_release_path (first_time)
** Execute deploy:new_release_path
** Execute deploy:updating
** Invoke git:create_release (first_time)
** Invoke git:update (first_time)
** Invoke git:clone (first_time)
** Invoke git:wrapper
** Execute git:clone
DEBUG[fa77f295] Running /usr/bin/env [ -f /var/www/my_app/repo/HEAD ] on {IP/Host}
DEBUG[fa77f295] Command: [ -f /var/www/my_app/repo/HEAD ]
DEBUG[fa77f295] Finished in 0.081 seconds with exit status 1 (failed).
DEBUG[0cc407cc] Running /usr/bin/env if test ! -d /var/www/my_app; then echo "Directory does not exist '/var/www/my_app'" 1>&2; false; fi on {IP/Host}
DEBUG[0cc407cc] Command: if test ! -d /var/www/my_app; then echo "Directory does not exist '/var/www/my_app'" 1>&2; false; fi
DEBUG[0cc407cc] Finished in 0.075 seconds with exit status 0 (successful).
INFO[de52ca0e] Running /usr/bin/env git clone --mirror [email protected]:jaipratik/rw.git /var/www/my_app/repo on {IP/Host}`enter code here`
DEBUG[de52ca0e] Command: cd /var/www/my_app && ( GIT_ASKPASS=/bin/echo GIT_SSH=/tmp/my_app/git-ssh.sh /usr/bin/env git clone --mirror [email protected]:jaipratik/rw.git /var/www/my_app/repo )
cap aborted!
SSHKit::Runner::ExecuteError: Exception while executing on host {IP/Host}: git exit status: 1
git stdout: Nothing written
git stderr: Nothing written
/Users/jay/.rvm/gems/ruby-2.1.0/gems/sshkit-1.5.1/
Just write the command in console:
ssh-add
If that don't work, write below command in console:
ssh-add ~/.ssh/id_rsa
and then re-run the command (i.e. cap production deploy
), It will work for sure.
If all the above solutions did not work for you, try this. It works for me. Cheer.
ssh-add ~/.ssh/your_private_id_rsa
and run
eval `ssh-agent`
Ref: http://mjacobus.github.io/2015/08/20/solving-weird-capistrano-problems-with-ssh-authentication.html
Capistrano wasn't able to create the folder on ec2. Once I created the folder it worked like a charm.
So if you also have similar issues try creating the folder on ec2 and then execute the cap production deploy.
So what are the permissions for /var/www/my_app
in your remote machine ? Make sure they are owned by the same user that you specified in this config option:
set :user, "mydeployuser"
If not I believe Capistrano defaults to the user you are using to run the 'cap' command on the client machine. Make sure that it has permissions to modify/create /var/www/my_app
Since you have:
set :use_sudo, true
it's possible that sudo may not be setup as passwordless sudo like suggested in the Cap 3 docs
I had this issue when trying to deploy a Rails application to a server using Capistrano.
When I run the command cap deploy
, I get the error:
SSHKit::runner::ExecuteError: Exception while executing as deploy
Here' how I fixed it:
The issue was that the server to which I was trying to deploy to did not have my SSH key authorized. I had to do the following:
Generate a new SSH key on my local machine:
ssh-keygen
Display the contents of the public file. In my case mine was id_rsa.pub
:
cat ~/.ssh/your-public-file
Login to the server which you want to deploy the app to:
ssh your-username@server-ip-address
Paste the contents of the public file into the ~/.ssh/authorized_keys
file on a new line.
That's all.
I hope this helps
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With