Webistrano/Capistrano problem with git
Recently I helped a friend debug a problem when deploying with Webistrano/Capistrano.
He was using a git repository and used SSH keys for authentication. Every time he tried to deploy he got this error:
executing locally: "git ls-remote ssh://repo.example.com/git/myproject.git HEAD" *** Could not save revision: Unable to resolve revision for 'HEAD' on repository 'ssh://repo.example.com/git/myproject.git'.
When running this command manually as the Webistrano user, everything worked fine.
We checked the usual suspects: the SSH key, the permissions on the SSH dirs/files, user, firewall & co. Everything seemed correct and worked when we ran the command by hand.
After a bit of tinkering I had the Eureka moment: the git command was not in $PATH when running under Passenger!
Git was installed and worked when we logged in as the Webistrano user. But when Passenger runs Webistrano it doesn't load all your shell config files. So if git is not in a standard location like /usr/bin or /bin Capistrano (which by this time will be called from Webistrano to do the actual deployment) will not find it.
I our case git was installed in /usr/local/bin and thus not in the default path. We ended up symlinking it to /usr/bin and everything worked like a charm.
I just committed a fix to Capistrano to make debugging such errors in the future easier. Capistrano will now check every local command it executes and see if it is in path. So with the latest version on github the error message would have looked like this:
executing locally: "git ls-remote ssh://repo.example.com/git/myproject.git HEAD" *** executable 'git' not present or not in $PATH on the local system! *** Could not save revision: Unable to resolve revision for 'HEAD' on repository 'ssh://repo.example.com/git/myproject.git'.
So if you are running any shell commands under Passenger remember that it doesn't use a full login-shell.
- Technology:
- Add new comment
- 389 reads
- Feed: BlogFish
- Original article


Recent comments
1 year 23 weeks ago
1 year 23 weeks ago
1 year 25 weeks ago
1 year 27 weeks ago
1 year 42 weeks ago
1 year 45 weeks ago
1 year 45 weeks ago
1 year 45 weeks ago
1 year 46 weeks ago
1 year 48 weeks ago