Why can't my post-receive hook run a virtualenv source command?
Asked Answered
B

1

6

I have a post-receive hook that is running as user 'git'. I have a virtualenv /python/ve//bin/activate that is readable by git. Running:

source /python/ve/<name>/bin/activate

works fine for a user in the git group.

When it runs as a post-receive hook after a push, I get the error "source: not found".

I'm not sure where else to look - any hints much appreciated.

Buffet answered 29/4, 2011 at 8:28 Comment(0)
L
14

This is something of a guess, since you haven't quoted your complete post-receive hook, but I suspect that you don't have a shebang line pointing to /bin/bash at the top. Your post-receive hook should begin:

#!/bin/bash

I suspect this because if I run a strict Bourne shell, like dash, I get the same error when trying to source anything with source.

Lenzi answered 29/4, 2011 at 8:32 Comment(2)
Brilliant. Thank you. I had accidentally had /bin/sh as I'd copied it from another person's hook. I'd just changed the shell for the git user, but forgot about the shebang line. Thank you for such a quick accurate answer.Buffet
No problem - it's very easy to do :)Lenzi

© 2022 - 2024 — McMap. All rights reserved.