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:

Running pre-commit hooks...
PHP Parse error:  parse error in /path/to/repo/vendor/peridot-php/peridot/bin/peridot on line 9

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!

  • Using git to deploy to staging and production versions to different locations
  • Deploying Fb app on Heroku
  • How to commit Composer vendor folder into Git repository?
  • Secondary project based on original branched project (in GIT)
  • php exec() not returning error message in output when executing svn command
  • Running 'git pull' using shell_exec in PHP not displaying error
  • Starting with versioning mysql schemata without overkill. Good solutions?
  • Using Codeigniter, how do I hide Paypal credentials from other developers?
  • One Solution collect form web for “Can't run peridot test suite from a git hook”

    Looks like 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 PATH searching.

    Git Baby is a git and github fan, let's start git clone.