Capistrano + Git – “unable to find”

I’m having difficulty setting up a workstation to use Capistrano to deploy a project. It’s a project that I worked on previously, in-house for a client. We used Capistrano + Git on this PHP project without difficulty.

Now I am trying to revisit the project and am setting up a workstation to be able to access the code through github and deploy it to the client server via Capistrano.

  • Trouble using Capistrano with a local git repository
  • Development process, deployment, GitHub
  • Trouble using capistrano 3 while deploying
  • SASS files management in Git version control system in Ruby on Rails
  • Do people commit their capistrano deploy.rb and recipes to their private scm?
  • Capistrano deploy on windows fails with git
  • I am having no difficulty connecting to github on either my workstation or the client server. I can execute SSH -vT git@github.com on my workstation and get the expected success result.

    Likewise I can shell into the server and execute the command to verify that the server can access github.com.

    On the workstation side I can clone, pull and push code without difficulty.

    However, when I try to run the capistrano deployment script, the script comes to the point of trying to execute the first fetch (or clone) and craps out with an “unable to find [commit SHA hash]” error.

    The deployment script hasn’t changed since the last time I deployed from the client office.

    Here is the output of the cap deploy:

      * 2012-11-14 18:52:34 executing `dev'
      * 2012-11-14 18:52:34 executing `setbranch'
      * 2012-11-14 18:52:34 executing `deploy'
      * 2012-11-14 18:52:34 executing `deploy:update'
     ** transaction: start
      * 2012-11-14 18:52:34 executing `deploy:update_code'
        updating the cached checkout on all servers
        executing locally: "git ls-remote git@github.com:XXX123/reponame.git master"
        command finished in 2490ms
      * executing "if [ -d /home/serverusername/dev.site.com/code/shared/cached-copy ]; then cd /home/serverusername/dev.site.com/code/shared/cached-copy && git fetch -q origin && git fetch --tags -q origin && git reset -q --hard 8d28f09e2b85ebac6da912-github-commit-sha && git clean -q -d -x -f; else git clone -q git@github.com:XXX123/reponame.git /home/serverusername/dev.site.com/code/shared/cached-copy && cd /home/serverusername/dev.site.com/code/shared/cached-copy && git checkout -q -b deploy 8d28f09e2b85ebac6da912-github-commit-sha; fi"
        servers: ["server.alias"]
        [server.alias] executing command
     ** [server.alias :: out] error: unable to find 8d28f09e2b85ebac6da912-github-commit-sha
     ** fatal: object 8d28f09e2b85ebac6da912-github-commit-sha not found
        command finished in 1681ms
     *** [deploy:update_code] rolling back
      * executing "rm -rf /home/serverusername/dev.site.com/code/releases/20121115025239; true"
        servers: ["server.alias"]
        [server.alias] executing command
        command finished in 293ms
    failed: "sh -c 'if [ -d /home/serverusername/dev.site.com/code/shared/cached-copy ]; then cd /home/serverusername/dev.site.com/code/shared/cached-copy && git fetch -q origin && git fetch --tags -q origin && git reset -q --hard 8d28f09e2b85ebac6da912-github-commit-sha && git clean -q -d -x -f; else git clone -q git@github.com:XXX123/reponame.git /home/serverusername/dev.site.com/code/shared/cached-copy && cd /home/serverusername/dev.site.com/code/shared/cached-copy && git checkout -q -b deploy 8d28f09e2b85ebac6da912-github-commit-sha; fi'" on server.alias
    

    (I’ve changed some of the names in the output code to project the client.)

    I initially encountered this problem while struggling to set things up on a Windows Vista PC. Thinking that Windows was the problem, I then set up an Ubuntu virtual box, got that up and running quickly, and am having the same result.

    Can anyone help?

  • How to pull specific directory with git
  • How to import and run project, in Android Studio 1.1, from Github?
  • Deploy via TeamCity from GitHub
  • Do both branches and tags both — literally speaking — refer to commits?
  • Git conflict when pulling from repo forked from me, even though last thing I did was pull from it
  • Ignore all the files in the root except for some particular files, directories
  • One Solution collect form web for “Capistrano + Git – “unable to find””

    I would agree with berkes that your cap recipe may be looking for the wrong SHA, but since you report that it hasn’t changed, I’ll throw out this possibility since it recently happened to me:

    Ensure that the SHA still exists on the branch.

    We rewrote some of our history, and the previous SHA’s were no longer in the repo. I’d look through git log for the SHA. It might be faster to just create a throw-away branch and reset to the SHA git checkout -b lost_sha && git reset --hard 8d28f09e2b85ebac6da912. Git would complain if the SHA wasn’t found.

    It’s possible that your script didn’t change, but the repo did.

    Git Baby is a git and github fan, let's start git clone.