After upgrading to Ubuntu 14.04 php-pear is failing to install any packages.

sudo pear install --alldeps --force pear.phpunit.de/PHPUnit
downloading PHPUnit-4.0.17.tgz ...
Starting to download PHPUnit-4.0.17.tgz (509,430 bytes)
......................................................................................................done: 509,430 bytes
could not extract the package.xml file from "/build/buildd/php5-5.5.9+dfsg/pear-build-download/PHPUnit-4.0.17.tgz"
Download of "phpunit/PHPUnit" succeeded, but it is not a valid package archive
Error: cannot download "phpunit/PHPUnit"
Download failed
install failed
The packages are being downloaded but can't extract.

I've tried this solution, http://cweiske.de/tagebuch/pear-php-5.5.htm But still getting the same problem.

Has anyone else encountered this? Do I need to downgrade to php5.4? If so, how?.

Update: Thanks for the quick responses. Karels answer solved my problem. Just for completeness the proper way to installing via pear no longer works. The steps to install from a phar file are documented at: http://phpunit.de/getting-started.html

Also it is no longer necessary include/require PHPunit/Runner.php and Autoload etc.

Again. Thanks for the help

  • 1
    This is a known bug. I am afraid that problems caused by bugs are off topic here.
    – terdon
    Apr 21, 2014 at 12:50
  • /usr/share/php/Archive/Tar.php can't open tgz files because line 734 is returning "false" when checking for gzopen. Google has a 5 year old bug (still open) that may be related: bugs.launchpad.net/ubuntu/+source/php5/+bug/451405 The solution is to find and replace the following in Tar.php: * Replace 'gzopen' with 'gzopen64' * Replace 'gzseek' with 'gzseek64' * Replace 'gztell' with 'gztell64'
    – jarederaj
    Nov 21, 2014 at 21:16

1 Answer 1


The easiest way to obtain PHPUnit is to download a PHP Archive (PHAR) that has all required (as well as some optional) dependencies of PHPUnit bundled in a single file.

Open the terminal and type:

wget https://phar.phpunit.de/phpunit.phar  # download the PHP Archive (PHAR) file  
chmod +x phpunit.phar  
sudo mv phpunit.phar /usr/local/bin/phpunit  

There are many different versions of phpunit.phar at https://phar.phpunit.de/. If you use the first command, it will select and download the latest version of phpunit.phar.

  • Thank you karel..I thiink the last line should be sudo mv phpunit.phar /usr/local/bin/phpunit. But that solved my problem
    – amurray
    Apr 21, 2014 at 14:59
  • +1 Tried all answers in stackoverflow.com/questions/12536668/… at first, but your answer solved it for me.
    – eddy147
    Sep 30, 2014 at 17:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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