I ran into this issue on my WordPress VIP Quickstart Vagrant box today while attempting to run PHPUnit:
1 2 3 4 5 6 7 8 9 10 11 |
vagrant@vip:/srv/www/path/to/plugin$ phpunit Warning: require_once(PHP/CodeCoverage/Filter.php): failed to open stream: No such file or directory in /usr/bin/phpunit on line 38 Call Stack: 0.0002 118636 1. {main}() /usr/bin/phpunit:0 Fatal error: require_once(): Failed opening required 'PHP/CodeCoverage/Filter.php' (include_path='.:/usr/share/php:/usr/share/pear') in /usr/bin/phpunit on line 38 Call Stack: 0.0002 118636 1. {main}() /usr/bin/phpunit:0 |
Figuring something had gone wonky with my server, I destroyed and re-provisioned my Vagrant box, only to get the following errors:
1 2 3 4 5 6 7 |
==> default: err: /Stage[main]/Php::Phpunit/Package[pear.phpunit.de/PHPUnit]/ensure: change from absent to present failed: Execution of '/usr/bin/pear upgrade pear.phpunit.de/PHPUnit' returned 1: Attempting to discover channel "pear.phpunit.de"... ==> default: downloading End-of-Life-for-PEAR-Installation-Method ... ==> default: Starting to download End-of-Life-for-PEAR-Installation-Method (Unknown size) ==> default: ......done: 28,088 bytes ==> default: unknown channel "pear.phpunit.de" in "pear.phpunit.de/PHPUnit" ==> default: invalid package name/package file "pear.phpunit.de/PHPUnit" ==> default: upgrade failed |
Ugh. As it turns out, PHPUnit has EOL‘d the PEAR installation method, which the VIP provisioner seems to use. There’s a ticket on Quickstart’s GitHub repository, but there doesn’t seem to be a coded patch at the time of this writing.
To resolve the issue in the short term, SSH into your VIP Quickstart instance and run the following to remove the PEAR version of PHPUnit:
1 |
$ pear uninstall phpunit/PHPUnit |
If you’re using a freshly-provisioned box, you might get an error like ‘unknown channel “phpunit” in “phpunit/PHPUnit”‘ – if so, don’t worry about it and go ahead and move on.
Then, you can install the PHPUnit PHAR globally by running the following, though you might also just load PHPUnit as you need it via Composer:
1 2 3 |
$ wget https://phar.phpunit.de/phpunit.phar $ chmod +x phpunit.phar $ mv phpunit.phar /usr/local/bin/phpunit |
Note: The mv
command may require the use of sudo
!
If you have problems with moving from PEAR to the PHAR, this article goes a bit more in-depth on the process.
Hopefully this saves someone else some time.
Leave a Reply