PHPUnit: Warning: require(PHPUnit/Autoload.php): failed to open stream: No such file or directory in /usr/local/bin/phpunit on line 42

udo picture udo · Nov 30, 2011 · Viewed 35.6k times · Source

when running

  • phpunit

I get error

Warning: require(PHPUnit/Autoload.php): failed to open stream: No such file or directory in /usr/local/bin/phpunit on line 42

Fatal error: require(): Failed opening required 'PHPUnit/Autoload.php' (include_path='.:') in /usr/local/bin/phpunit on line 42

/usr/local/bin/phpunit displays the following on line 42:

require 'PHPUnit/Autoload.php';

any suggestions how to fix this?

Update (1):

I was missing php.ini in /etc/, so I symlinked it to read the MAMP php.ini. Now I get

php -r 'foreach (explode(":", get_include_path()) as $path) echo $path . PHP_EOL;'
.
/Applications/MAMP/bin/php/php5.3.6/lib/php
/usr/local/bin/pear
/usr/local/share/pear/PHPUnit

running

  • phpunit

is running but provides no output.

Any suggestions what to check next?

Update (2):

probably the root cause of this issue is related to question

Answer

warhod picture warhod · Jan 18, 2012

I hit a similar issue on MAC OSX Lion. I installed phpunit with the PEAR package manager, and when I try to run it I got the error as described by udo. I was able to resolve it with the following simple steps:

  1. Get the latest php archive of pear curl http://pear.php.net/go-pear.phar > go-pear.php
  2. Install the archive with sudo php -q go-pear.php

During installation, it detects if the include_path in your php.ini does not contain the PEAR PHP directory. You can choose to let it fix it for you automatically when given the option.