9

I have a simple deployment via capistrano from a Git repository.

I wanted to change the repository I was working with so I basically just changed

set :repository, "git@github.com:new_repository"

But i get the following error when deploying:

fatal: Could not parse object '9cfb...'.

The problem goes away once I change

set :deploy_via, :remote_cache

to

set :deploy_via, :copy

I also tried deploy:cleanup but I get the following error:

*`deploy:cleanup' is only run for servers matching {:except=>{:no_release=>true}}, but no servers matched*

Any idea how could i get remote_cache working again?

Thansk!

Hans
  • 237
  • 5
  • 13
  • possible duplicate of [Capistrano deploy fails after I changed the repository URL](http://stackoverflow.com/questions/8358238/capistrano-deploy-fails-after-i-changed-the-repository-url) – slhck Jan 31 '14 at 09:48

7 Answers7

13

With capistrano 3, to avoid deleting the repo folder :

  1. Change the repo URL in your config/deploy.rb, as the OP already did

  2. SSH to your server inside and change the remote URL of the git repo :

    ssh user@server.com  
    # Go the capistrano deploy root
    cd /capistrano/deploy/root/folder  
    # Go inside the folder names *repo*
    cd repo  
    # Manually change the git remote
    git remote set-url origin ...
    
Vala
  • 537
  • 6
  • 13
11

Capistrano < 3

Fix it in ./shared/cached-copy/.git/config from deployment folder of your server.

OR ugly way do this:

Remove the shared/cached-copy from deployment folder of your server.

Capistrano > 3

Fix it in ./repo/config from deployment folder of your server.

Learn How to fix similar issues

It is caused as your server files are referring to old repo so you have to find and fix it. Do this to find matches in files:

cd /path/to/your/project
grep -r OLD_REPO_NAME ./

Now you see all files including your OLD_REPO_NAME . If they are matched in your release folder or current, you dont need to care for fixing them. But you should fix all configs.

user1553777
  • 241
  • 3
  • 7
6

you can just change the git url in

shared/cached-copy/.git/config
stef
  • 525
  • 6
  • 14
6

Additional info for Capistrano 3 users. Capistrano will create a folder repo. So the structure looks like this:

current -> /var/www/preview/releases/20140612212305
releases
repo
revisions.log
shared

When you change the :repo_url in deploy.rb you can safely remove the repo folder and run the deployment. The folder will be created again. The reason why you have to do this step is because in repo/config is the old remote url.

awenkhh
  • 5,811
  • 1
  • 21
  • 24
3

ssh to your production server and delete the content of your shared/cache folder. The git ref stored in there is not valid anymore so it won't work.

mathieugagne
  • 2,465
  • 1
  • 17
  • 18
  • Hi Mathieu. I removed everything inside shared/cached-copy and got the same error, then I removed it and got this error: _ERROR: Repository not found_ – Hans May 27 '13 at 03:08
  • Yeah you need the folder for sure. It usually works for me. I've always fixed that issue the same way. Let me see – mathieugagne May 27 '13 at 12:48
  • Thanks! I've been struggling for a while with this problem without any results. – Hans May 27 '13 at 16:20
  • These doesn't work with Capistrano 3, change the url in repo/config file. Shared/cache folder doesn't exist – hemc4 Jan 08 '15 at 10:44
0

Just add task into deploy.rb to sync it automagically.

$ cap admin:fix_repo

  namespace :admin do
    desc 'Fix repo'
    task :fix_repo, :roles => :web do
      run "cd #{shared_path}/cached-copy && git remote set-url origin #{repository}"
    end
  end
merqlove
  • 3,674
  • 1
  • 23
  • 22
0

As related to this thread, after updated your deploy.rb with

set :repository, "git@github.com:new_repository"

go to your server with ssh deploy-user, then cd Old_repository/repoand sudo vim config

You'll find the line url = git@github.com:username/old_repository.git and you have to rename it with url = git@github.com:username/new_repository.git

Don't forget to delete the Old_repository folder on your server, or just rename it before in New_repository folder !

OBrooks
  • 343
  • 1
  • 3
  • 7