Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Capistrano error when change repository using git

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, "[email protected]: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!

like image 667
Hans Avatar asked May 26 '13 23:05

Hans


4 Answers

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 [email protected]  
    # 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 ...
    
like image 162
Vala Avatar answered Nov 16 '22 04:11

Vala


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.

like image 29
awenkhh Avatar answered Nov 16 '22 03:11

awenkhh


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.

like image 39
user1553777 Avatar answered Nov 16 '22 04:11

user1553777


you can just change the git url in

shared/cached-copy/.git/config
like image 6
stef Avatar answered Nov 16 '22 03:11

stef