Can't run peridot test suite from a git hook
I have made the following pre-commit git hook:
#/usr/bin/env bash echo "Running pre-commit hooks... " vendor/bin/peridot -c OS/Specs/peridot.php OS/Specs/ echo "Done."
When I simply enter this command into terminal, it runs all my tests. However, when the git hook is triggered, I get this:
- Generate a version number of my site thanks to git?
- How to deploy a plugin to Heroku
- Can't update/install using composer behind a corporate firewall
- Git autodeploy on Windows 2003 with WAMP
- Git - Exclude a config file from post-receive checkout
- Composer downloads entire .git repo directory
Running pre-commit hooks... PHP Parse error: parse error in /path/to/repo/vendor/peridot-php/peridot/bin/peridot on line 9 Done.
The offending line contains a bracketed array . When I change to the old array() syntax, the error goes away (and is replaced with another one farther down). Furthermore, when I run
php -v in both places, I get:
PHP 5.4.24 (cli) (built: Jan 30 2014 10:18:21)
PHP 5.3.28 (cli) (built: Jan 23 2014 18:02:48)
Why is my Git hook using the wrong version of PHP? How can I fix this? Thanks!
One Solution collect form web for “Can't run peridot test suite from a git hook”
vendor/bin/peridot is a PHP script, since you pointed out it starts with a PHP hashbang (
#!/usr/bin/env php). It looks like your Git environment has a different
PATH to your usual user account, and so it sees an older version of PHP first.
The trick in this case is to hardwire the version of PHP in your commit hook, so it doesn’t have to do any