0

I'v been trying to get phpunit up and running but for some reason i'm stuck with the following error:

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

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

Does anybody have a clue how to solve this?

Thanks in advance!

Peter

4 Answers 4

2

Your include path is not setup. Follow the instructions at http://pear.php.net/manual/en/installation.checking.php

Also check if you installed phpunit in the correct directory:

$ pear list-files phpunit/phpunit

PHPUnit/Autoload.php should be listed there, in the patch you added to the include path.


Update: the problem was that @Peter had 2 php.ini files, and he edited the wrong one.

Find the correct one with

$ php --ini
9
  • I added the include path in the php.ini and when I open zendserver CE it shows the path but i'm still getting the same error.
    – Sephen
    Nov 7, 2011 at 15:27
  • In the list which the "$ pear list-files..." command returns is a line: php /usr/share/pear/PHPUnit/Autoload.php. I assume that's right. But still the same.
    – Sephen
    Nov 8, 2011 at 7:27
  • what is your exact include path now?
    – cweiske
    Nov 8, 2011 at 9:36
  • It's: ".:/usr/local/zend/share/ZendFramework/library:/usr/share/pear"
    – Sephen
    Nov 8, 2011 at 9:42
  • I don't exactly know what you mean but in the "/usr/share/pear" directory is the "PHPUnit/Autoload.php".
    – Sephen
    Nov 8, 2011 at 9:49
2

Irakli's post was the most helpful.

I'm on Mac OS X 10.7.2 and I use Homebrew to install packages. Homebrew put php in /usr/local/bin/php.

Following Irakli's hint that phpunit is using a different version on of PHP (even though it was using the same php.ini file), I edited /usr/bin/phpunit, replacing this:

#!/usr/bin/php

with this:

#!/usr/local/bin/php

(Irakli's suggestion of "#!/usr/bin/env php" didn't work for me)

Now phpunit can find "File/Iterator/Autoload.php" which is was having trouble with before, so I guess it's in the path now.

0
1

On Mac Lion I added the include path:

/usr/lib/php/pear/

to /private/etc/php.ini which solved the error.

1

In some cases (e.g. when using brew-installed PHP on OS-X Leopard/Snow Leopard/Lion) the problem can be that there're multiple php versions installed and phpunit is picking wrong one.

There's an easy solution, sudo-edit /usr/bin/phpunit and replace #!/usr/bin/php with #!/usr/bin/env php

Somebody should probably submit a bug to phpunit, referring to PHP executable directly is really careless.

1
  • Sir, I had to use /usr/local/bin/php to get this to work. I'm guessing homebrew has switched the location of php since this was posted. Dec 16, 2013 at 16:07

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.