phpunit: PHPUnit won't install via Composer on PHP7.2

Q A
PHPUnit version 7.0.2
PHP version 7.2.2-3+ubuntu16.04.1+deb.sury.org+1
Installation Method Composer
vagrant@homestead:~/Code/project$ composer require --dev phpunit/phpunit ^7
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - Installation request for sebastian/diff (locked at 2.0.1) -> satisfiable by sebastian/diff[2.0.1].
    - phpunit/phpunit 7.0.0 requires sebastian/diff ^3.0 -> satisfiable by sebastian/diff[3.0.0].
    - phpunit/phpunit 7.0.1 requires sebastian/diff ^3.0 -> satisfiable by sebastian/diff[3.0.0].
    - phpunit/phpunit 7.0.2 requires sebastian/diff ^3.0 -> satisfiable by sebastian/diff[3.0.0].
    - Conclusion: don't install sebastian/diff 3.0.0
    - Installation request for phpunit/phpunit ^7 -> satisfiable by phpunit/phpunit[7.0.0, 7.0.1, 7.0.2].


Installation failed, reverting ./composer.json to its original content.
vagrant@homestead:~/Code/project$

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 6
  • Comments: 17 (2 by maintainers)

Most upvoted comments

Thanks @mvuajua! I got this error when trying to upgrade my phpunit by requiring it again. Solution for me was to uninstall phpunit and reinstall it:

$ composer remove phpunit/phpunit --dev
$ composer require phpunit/phpunit --dev

What is the solution for this problem?

If it can help someone:

If you want for example upgrade to phpunit ^9 without remove/require:

composer require --dev --update-with-dependencies phpunit/phpunit:^9

You have sebastian/diff locked to a version that is not compatible with the version of PHPUnit you are trying to install. This is not a PHPUnit issue.

No response and nothing to add nethertheless… And he closed the thread šŸ‘Ž

I had the same problem, even though sebastian/diff was not locked down anywhere (and only required to be ^2 by phpunit itself according to composer why).

Only solution for me was to uninstall phpunit (triggering an uninstall of sebastian/diff as well) and then to reinstall phpunit.

I solved by running sudo apt-get update sudo apt install php-xml

This update other related sebastian dependencies as well so this solution works $ composer remove phpunit/phpunit --dev $ composer require phpunit/phpunit --dev

You have sebastian/diff locked to a version that is not compatible with the version of PHPUnit you are trying to install. This is not a PHPUnit issue.