0

I'm running OSX 10.6.5 with Git 1.7.1

I have git installed in a non-standard location (though that really should be the standard on a mac;-) in /Library/Frameworks/Git.framework. My own PATH is set fine, git works fine, until... I set up a pre-commit hook with a Ruby script:

$ git commit -m "added some Yard documentation" .git/hooks/pre-commit: line 1: #!/usr/bin/env: No such file or directory 

The pre-commit.sample runs ok, so it appears that git can't find /usr/bin/env, or much else as I've tried shebanging it directly to ruby etc. Just /bin/sh is ok.

So, where does Git get it's PATH? because it's not using mine or this wouldn't be happening. And more to the point, how do I get it to see /usr/bin/env ?

I've tested the ruby script already, it works.


Just to add:

$ cat /etc/paths /usr/bin /bin /usr/sbin /sbin /usr/local/bin $ cat /etc/paths.d/git /Library/Frameworks/Git.framework/Programs 

The first few lines of the Ruby script (which runs via ./pre-commit or ruby pre-commit)

#!/usr/bin/env ruby -wKU class String def expand_path File.expand_path self end def parent_dir File.dirname self.expand_path end end 
6
  • 1
    If its failing on an absolute executable, its not doing this because of your path. It means that its actively unable to find the command /usr/bin/env on your system, and your PATH has nothing to do with it. Commented Mar 6, 2011 at 14:49
  • 1
    It's not saying it can't find "/usr/bin/env", it's saying it can't find "#!/usr/bin/env". If you show the first few lines of the file, we might be able to see the problem. Commented Mar 6, 2011 at 14:50
  • 1
    @Redmumba: That should give a "bad interpreter message", but you're right about the absolute path. Commented Mar 6, 2011 at 14:51
  • You are absolutely right; I was looking over the message and noticed it was saying it couldn't find #!/usr/bin/env, not just /usr/bin/env. Commented Mar 6, 2011 at 14:56
  • 1
    Are you sure that's the exact contents of your git hook? I.e., cat .git/hooks/pre-commit? Commented Mar 6, 2011 at 14:59

1 Answer 1

0

File was corrupted somehow from the time I'd copied it in to .git/hooks, a new file with same code fixed it. Many thanks to @Redmumba and @Dennis Williamson for letting me know I was looking in the wrong place.

1
  • Awesome! Please mark your answer as correct, just so the question will be closed off. :) Commented Mar 6, 2011 at 21:17

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.