9

I am trying to use capistrano (for the first time) to deploy my rails app. First the essentials, I am using:

  • ruby 1.9.3p362
  • Rails 3.2.13
  • rvm 1.24.7
  • Capistrano 3.0.1
  • Phusion Passenger 4.0.26
  • Ubuntu 12.04 LTS

I get the following error when attempting to run cap production deploy

DEBUG [679a47be] fatal: No remote configured to list refs from.

My full cap production deploy output is included below

   INFO [488ba755] Running /usr/bin/env mkdir -p /tmp/AppName/ on sub.example.com
    DEBUG [488ba755] Command: /usr/bin/env mkdir -p /tmp/AppName/
     INFO [488ba755] Finished in 1.730 seconds with exit status 0 (successful).
    DEBUG Uploading /tmp/AppName/git-ssh.sh 0.0%
     INFO Uploading /tmp/AppName/git-ssh.sh 100.0%
     INFO [c895f068] Running /usr/bin/env chmod +x /tmp/AppName/git-ssh.sh on sub.example.com
    DEBUG [c895f068] Command: /usr/bin/env chmod +x /tmp/AppName/git-ssh.sh
     INFO [c895f068] Finished in 0.217 seconds with exit status 0 (successful).
    DEBUG [679a47be] Running /usr/bin/env git ls-remote  on sub.example.com
    DEBUG [679a47be] Command: ( GIT_ASKPASS=/bin/echo GIT_SSH=/tmp/AppName/git-ssh.sh /usr/bin/env git ls-remote  )
    DEBUG [679a47be]  fatal: No remote configured to list refs from.
    DEBUG [679a47be] Finished in 1.775 seconds with exit status 128 (failed).

Gemfile

# Deploy with Capistrano
gem 'capistrano',  '~> 3.0.0'
gem 'capistrano-rails', '~> 1.1.0'
gem 'rvm1-capistrano3', require: false

Capfile

# Load DSL and Setup Up Stages
require 'capistrano/setup'

# Includes default deployment tasks
require 'capistrano/deploy'

# require 'capistrano/rvm'
# require 'capistrano/rbenv'
# require 'capistrano/chruby'
require 'capistrano/bundler'
require 'capistrano/rails/assets'
require 'capistrano/rails/migrations'

# Loads custom tasks from `lib/capistrano/tasks' if you have any defined.
Dir.glob('lib/capistrano/tasks/*.cap').each { |r| import r }

deploy.rb

I have altered this file to add my git url, the app name, the deploy_to path, and the tasks inside task :restart as directed to restart Phusion Passenger.

set :application, 'AppName'
set :deploy_to, '/var/www/appname'

set :repository, "git@github.com:username/appname.git"  # Your clone URL
set :scm, "git"
set :user, "my-github-deploy-user"  # The server's user for deploys
set :scm_passphrase, "correct-password"  # The deploy user's password
set :branch, "master"
set :deploy_via, :remote_cache

# ask :branch, proc { `git rev-parse --abbrev-ref HEAD`.chomp }

set :ssh_options, {
   verbose: :debug
}

set :format, :pretty
set :log_level, :debug
# set :pty, true

set :linked_files, %w{config/database.yml}
set :linked_dirs, %w{bin log tmp/pids tmp/cache tmp/sockets vendor/bundle public/system}

# set :default_env, { path: "/opt/ruby/bin:$PATH" }
# set :keep_releases, 5

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')
      # task :start do ; end
      # task :stop do ; end
      # task :restart, :roles => :app, :except => { :no_release => true } do
      #   run "#{try_sudo} touch #{File.join(current_path,'tmp','restart.txt')}"
      # end
    end
  end

  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
  after :finishing, 'deploy:cleanup'
end

I tried to included all necessary information, please let me know if there is anything else I can add, thanks for any help you can provide!

Thomas
  • 2,426
  • 3
  • 23
  • 38

1 Answers1

26

In Capistrano 3, you use repo_url instead of repository

So in your deploy.rb, try replacing

set :repository, "git@github.com:username/appname.git"  # Your clone URL

with

set :repo_url, "https://github.com/username/appname.git"  # Your clone URL

Hopefully this helps.

Update: The ssh URL needs a key; the https URL does not. It's worked for me.

jjmerelo
  • 22,578
  • 8
  • 40
  • 86
strivedi183
  • 4,749
  • 2
  • 31
  • 38
  • Thanks this moved me past that error and onto `Permission denied (publickey).` I ssh'ed into my server and walked through https://help.github.com/articles/error-permission-denied-publickey to ensure this was correct on the git/github side, with that eliminated as the cause of error, is this also a capistrano issue? – Thomas Dec 06 '13 at 15:40
  • Not sure if that's a capistrano issue or not to be honest, usually I think that error is when your server doesn't have access to github and I think you solved it at least the way I would have – strivedi183 Dec 10 '13 at 17:13
  • FUUUUU***CK yea. Thanks for the help mang. This did it for me. Know how many days I've been working on this? Jayzuz. – Nick Res Mar 25 '15 at 02:42
  • Please check the updated answer. The https URL always have read-only access. – jjmerelo Sep 26 '16 at 16:03
  • 1
    @jjmerelo The git URL will _not_ always have read-only access if the repo is private. – siannopollo Nov 11 '19 at 17:18