views:

234

answers:

4

Hey All,

I searched all of the relevant Capistrano issues, but couldn't find something that even elucidated anything here for me.

git version 1.6.4.2
Capistrano v2.5.10

Basically, when I run my cap deploy.rb script, it connects to the server, starts executing the deploy:update task, then in the deploy:update_code task:

    *** [deploy:update_code] rolling back
  * executing "rm -rf /home/user_name/public_html/project_name/releases/20091223094358; true"
    servers: ["project_name.com"]

It fails with the following error:

/Library/Ruby/Gems/1.8/gems/capistrano-2.5.10/lib/capistrano/recipes/deploy/scm/git.rb:231:in `query_revision': Unable to resolve revision for 'master' on repository 'ssh://git@slice_ip:path_to_git_repository'. (RuntimeError)

Here's my deploy script, I've tried including and omitting:

set :branch 'master'

I also just thought my path to the repository was off, but i've tried just about every permutation (absolute, not absolute, .git suffix, no suffix). There's definitely a bare git repository at the path i'm pointing to.

**I do have multiple projects being hosted on one slice. The other projects is also a rails project, but is running SVN. Capistrano deployments work fine.

Any pointers in the right direction or any ideas would help reduce the amount of drinking I am planning on doing if I can't figure this out. (Paths / IPs obfuscated, dont hack me bro!)

set :application, "project1"
set :user, "username"
set :repository,  "ssh://[email protected]/home/git/project1.git"
set :branch, "master" 

set :port, 696969

set :deploy_to, "/home/username/public_html/#{application}"

set :scm, :git

role :app, application                    
role :web, application                    
role :db,  application, :primary => true 

# deployment via remote client (workstation)
set :deploy_via, :copy 
set :runner, user

# mod_rails
namespace :deploy do
  desc "Restarting mod_rails with restart.txt"
  task :restart, :roles => :app, :except => { :no_release => true } do
    run "touch #{current_path}/tmp/restart.txt"
  end

  [:start, :stop].each do |t|
    desc "#{t} task is a no-op with mod_rails"
    task t, :roles => :app do ; end
  end
end

This was the most relevant post (extremely relevant even), but I couldn't really figure out what they were saying the fix is. I'm pretty new with git / capistrano configs.

https://capistrano.lighthouseapp.com/projects/8716/tickets/56-query%5Frevision-unable-to-resolve-revision-for-head-on-repository

A: 

For me Capistrano deployments with Git only seem to work when setting set :copy_cache, true

Htbaa
A: 

Both your workstation and your server must be able to reach the repository at the address specified, if not then you may have to set :local_repository to how you access it from your workstaion, and :repository to be how your servers should access it.

Beaks
A: 

I've only used capistrano with git once, but never used or seen the use of ssh:// in the repository definition.

Try using set :repository, "[email protected]/home/git/project1.git" instead

Craig Gardner
+2  A: 

Ok I seemed to have fixed it.

Basically, since I have 2 separate repositories on the remote server, I think the "git" user was failing because I hadn't registered an ssh keypair for the git user. That explains why one of my deploy.rb scripts was working properly, while this one wasn't.

In the link I posted in the question, one of the commenters pointed out the issue:

https://capistrano.lighthouseapp.com/projects/8716/tickets/56-query%5Frevision-unable-to-resolve-revision-for-head-on-repository

Note this error is also displayed if you are using multiple github keys per http://capistrano.lighthouseapp.... and you do not have these keys and a corresponding entry in your .ssh/config on the workstation you're running the deploy from. so the ls-remote is run locally. is there a way to reference the repository at github.com for this request while the remote deploy uses git@github-project1:user/project1.git

Also, see the following link for more details, since the whole ssh issue would apply even if you're not using github.

http://github.com/guides/multiple-github-accounts

ajhit406