I've been trying to solve this problem for some time.
I'm working with Ruby on Rails, using Capistrano to deploy from a BitBucket repository, and when I run cap production deploy
it ends up with the following error:
...
...
DEBUG [71effca7] Running /usr/local/rvm/bin/rvm default do ruby --version as user@MyHostIP
DEBUG [71effca7] Command: /usr/local/rvm/bin/rvm default do ruby --version
DEBUG [71effca7] ruby 2.2.4p230 (2015-12-16 revision 53155) [x86_64-linux]
DEBUG [71effca7] Finished in 0.750 seconds with exit status 0 (successful).
ruby 2.2.4p230 (2015-12-16 revision 53155) [x86_64-linux]
INFO [b9bac9f3] Running /usr/bin/env mkdir -p /tmp/MyAppName/ as user@MyHostIP
DEBUG [b9bac9f3] Command: /usr/bin/env mkdir -p /tmp/MyAppName/
INFO [b9bac9f3] Finished in 0.255 seconds with exit status 0 (successful).
DEBUG Uploading /tmp/MyAppName/git-ssh.sh 0.0%
INFO Uploading /tmp/MyAppName/git-ssh.sh 100.0%
INFO [2cd4cd4c] Running /usr/bin/env chmod +x /tmp/MyAppName/git-ssh.sh as user@MyHostIP
DEBUG [2cd4cd4c] Command: /usr/bin/env chmod +x /tmp/MyAppName/git-ssh.sh
INFO [2cd4cd4c] Finished in 0.247 seconds with exit status 0 (successful).
INFO [1643a10f] Running /usr/bin/env git ls-remote --heads as user@MyHostIP
DEBUG [1643a10f] Command: ( export GIT_ASKPASS="/bin/echo" GIT_SSH="/tmp/MyAppName/git-ssh.sh" ; /usr/bin/env git ls-remote --heads )
DEBUG [1643a10f] usage: git ls-remote [--heads] [--tags] [-u <exec> | --upload-pack <exec>] <repository> <refs>...
(Backtrace restricted to imported tasks)
cap aborted!
SSHKit::Runner::ExecuteError: Exception while executing as user@MyHostIP: git exit status: 129
git stdout: usage: git ls-remote [--heads] [--tags] [-u <exec> | --upload-pack <exec>] <repository> <refs>...
git stderr: Nothing written
SSHKit::Command::Failed: git exit status: 129
git stdout: usage: git ls-remote [--heads] [--tags] [-u <exec> | --upload-pack <exec>] <repository> <refs>...
git stderr: Nothing written
Tasks: TOP => git:check
(See full trace by running task with --trace)
The deploy has failed with an error: Exception while executing as user@MyHostIP: git exit status: 129
git stdout: usage: git ls-remote [--heads] [--tags] [-u <exec> | --upload-pack <exec>] <repository> <refs>...
git stderr: Nothing written
/var/www/html/current/config/deploy.rb file:
# config valid only for current version of Capistrano
lock '3.4.0'
set :application, 'MyApp'
set :repo_url, 'git@bitbucket.org:user/repository.git'
# Default branch is :master
# ask :branch, `git rev-parse --abbrev-ref HEAD`.chomp
# Default deploy_to directory is /var/www/my_app_name
set :deploy_to, '/var/www/html'
# Default value for :scm is :git
set :scm, :git
set :branch, "master"
set :rails_env, "production"
# Default value for :format is :pretty
set :format, :pretty
set :passenger_restart_with_touch, true
# Default value for :log_level is :debug
# set :log_level, :debug
# Default value for :pty is false
set :pty, true
# Default value for :linked_files is []
# set :linked_files, fetch(:linked_files, []).push('config/database.yml', 'config/secrets.yml')
# Default value for linked_dirs is []
# set :linked_dirs, fetch(:linked_dirs, []).push('log', 'tmp/pids', 'tmp/cache', 'tmp/sockets', 'vendor/bundle', 'public/system')
# Default value for default_env is {}
# set :default_env, { path: "/opt/ruby/bin:$PATH" }
# Default value for keep_releases is 5
set :keep_releases, 5
namespace :deploy do
# 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
task :seed do
on roles(:all) do
execute "cd #{current_path}; bundle exec rake db:seed RAILS_ENV=#{fetch(:rails_env)}"
end
end
task :reset do
on roles(:all) do
execute "cd #{current_path}; bundle exec rake db:reset RAILS_ENV=#{fetch(:rails_env)}"
end
end
end
/var/www/html/repo/config file:
[core]
repositoryformatversion = 0
filemode = true
bare = true
[remote "origin"]
fetch = +refs/*:refs/*
mirror = true
url = git@bitbucket.org:user/repository.git
/var/www/html/current/config/deploy/production.rb file:
# server-based syntax
# ======================
# Defines a single server with a list of roles and multiple properties.
# You can define all roles on a single server, or split them:
# server 'example.com', user: 'deploy', roles: %w{app db web}, my_property: :my_value
# server 'example.com', user: 'deploy', roles: %w{app web}, other_property: :other_value
# server 'db.example.com', user: 'deploy', roles: %w{db}
set :stage, :production
server 'MyHostIP', user: 'user', roles: %w{web app db}
# role-based syntax
# ==================
# Defines a role with one or multiple servers. The primary server in each
# group is considered to be the first unless any hosts have the primary
# property set. Specify the username and a domain or IP for the server.
# Don't use `:all`, it's a meta role.
# role :app, %w{deploy@example.com}, my_property: :my_value
# role :web, %w{user1@primary.com user2@additional.com}, other_property: :other_value
# role :db, %w{deploy@example.com}
role :app, %w{user@MyHostIP}
role :web, %w{user@MyHostIP}
role :db, %w{user@MyHostIP}
# Configuration
# =============
# You can set any configuration variable like in config/deploy.rb
# These variables are then only loaded and set in this stage.
# For available Capistrano configuration variables see the documentation page.
# http://capistranorb.com/documentation/getting-started/configuration/
# Feel free to add new variables to customise your setup.
# Custom SSH Options
# ==================
# You may pass any option but keep in mind that net/ssh understands a
# limited set of options, consult the Net::SSH documentation.
# http://net-ssh.github.io/net-ssh/classes/Net/SSH.html#method-c-start
#
# Global options
# --------------
set :ssh_options, {
forward_agent: false,
auth_methods: %w(password),
password: 'password',
user: 'user',
port: 2178
}
I hope you can help me. I don't know what to do!!
Thank you!