2

If add git hook to pre-commit with following code then you get error "Error!" in PHPStorm.

#!/usr/bin/sh
echo "Error!"
exit 1

But if implement this on PHP you cannot get this error message in PHPStorm.

#!/usr/bin/php
<?php
echo "Error!";
exit(1);

PHPStorm return not understandable error:

error: cannot spawn .git/hooks/pre-commit: No such file or directory

Any ideas how to resolve this problem?

P.S. In command prompt all is ok.

6
  • Would #!/usr/bin/env php work better? Commented Sep 5, 2012 at 11:23
  • Maybe something wrong, but I got error: /bin/env: php: No such file or directory (Windows 7) Commented Sep 5, 2012 at 13:05
  • Strange: is php in your %PATH%? try with php.exe perharps? Commented Sep 5, 2012 at 13:22
  • Yes! Thx a lot! This resolve a problem. May be you can add answer? I'll mark it as answer. Commented Sep 5, 2012 at 13:28
  • Another problem. Hooks doesn't work in console. Exactly hooks cannot generate errors. I'll debug them... Commented Sep 5, 2012 at 14:19

1 Answer 1

2

If php.exe is in your %PATH%, you can ask for the shebang to look for it:

#! /usr/bin/env php.exe 
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.