PHPUnit install on Ubuntu (problem fix)

If you try to install PHPUnit on Ubuntu over:

sudo apt-get install phpunit
you may fall in big trouble, since there are some broken dependencies in that package. PHPUnit relies on Code_Coverage which can't be installed through repository packages and, trying to run phpunit, you'll get:
tomasz@workshop:~# phpunit 
PHP Fatal error:  Call to undefined method PHP_CodeCoverage_Filter::getInstance() in /usr/bin/phpunit on line 39
PHP Stack trace:
PHP   1. {main}() /usr/bin/phpunit:0
You can also have problems in connecting to phpunit.de pear service over SSL:
Warning: fsockopen(): unable to connect to ssl://pear.phpunit.de:443 (Connection refused) in PEAR/Downloader.php on line 1610
PHP Warning:  fsockopen(): unable to connect to ssl://pear.phpunit.de:443 (Connection refused) in /usr/share/php/PEAR/Downloader.php on line 1610
PHP Stack trace:
PHP   1. {main}() /usr/share/php/pearcmd.php:0
PHP   2. PEAR_Command_Common->run() /usr/share/php/pearcmd.php:305
PHP   3. PEAR_Command_Install->doInstall() /usr/share/php/PEAR/Command/Common.php:271
PHP   4. PEAR_Downloader->download() /usr/share/php/PEAR/Command/Install.php:661
PHP   5. PEAR_Downloader->downloadHttp() /usr/share/php/PEAR/Downloader.php:338
PHP   6. fsockopen() /usr/share/php/PEAR/Downloader.php:1610
There has been developed a workaround solution for this bug, which can save your day. You have to discover all 3 pear channels that pear PHPunit depends on and then you may (providing that you've removed the mess you had until now):
sudo apt-get remove phpunit
sudo apt-get upgrade pear
sudo pear channel-discover pear.phpunit.de
sudo pear channel-discover pear.symfony-project.com
sudo pear channel-discover components.ez.no
sudo pear update-channels
sudo pear upgrade-all
sudo pear install --alldeps phpunit/PHPUnit
The problem was noticed in the beginning of 2011 and it's still there.

2 comments:

  1. Hi,

    this channel works for me to Yaml-2.1.7:
    sudo pear channel-discover pear.symfony.com

    Cheers Tobias

    ReplyDelete
    Replies
    1. exactly that was missing. Thanks Anonymous ;)

      Delete