sebastianbergmann / phpunit

The PHP Unit Testing framework.
https://phpunit.de/
BSD 3-Clause "New" or "Revised" License
19.69k stars 2.2k forks source link

Installation using PHP 7.0 fails due to doctrine/instantiator 1.1.0 dependency #2823

Closed SeinopSys closed 7 years ago

SeinopSys commented 7 years ago
Q A
PHPUnit version 6.4
PHP version 7.0.22
Installation Method Composer

I'm trying to add PHPUnit as a dev dependency to a project of mine, which seems to fail on PHP 7.0 and prevents tests from succeeding. Travis CI gives me the following during the build process:

$ composer --version
Composer version 1.5.2 2017-09-11 16:59:25
0.27s

$ composer install
Loading composer repositories with package information
Installing dependencies (including require-dev) from lock file
Your requirements could not be resolved to an installable set of packages.

 Problem 1
 - Installation request for doctrine/instantiator 1.1.0 -> satisfiable by doctrine/instantiator[1.1.0].
 - doctrine/instantiator 1.1.0 requires php ^7.1 -> your PHP version (7.0.22) does not satisfy that requirement.
 Problem 2
 - doctrine/instantiator 1.1.0 requires php ^7.1 -> your PHP version (7.0.22) does not satisfy that requirement.
 - phpunit/phpunit-mock-objects 4.0.4 requires doctrine/instantiator ^1.0.5 -> satisfiable by doctrine/instantiator[1.1.0].
 - Installation request for phpunit/phpunit-mock-objects 4.0.4 -> satisfiable by phpunit/phpunit-mock-objects[4.0.4].

The command "composer install" failed and exited with 2 during .

Your build has been stopped.

The issue can only be with PHPUnit as it's the only dependency in the repository, and it does not happen when using PHP 7.1

kubawerlos commented 7 years ago

Remove composer.lock and vendor directory and try again.

localheinz commented 7 years ago

Or run

$ composer remove phpunit/phpunit && require --dev phpunit/phpunit:^6.4 --update-with-dependencies

This should help as well without the need to remove composer.lock (as a subsequent composer install might pull in undesired updates).

SeinopSys commented 7 years ago

Removing composer.lock did it, thank you @kubawerlos!

vsasvipul0605 commented 4 years ago

I have this same error. but I can't delete the composer.lock file as the same repository I'm deploying on heroku and build starts failing on heroku without composer.lock file

SeinopSys commented 4 years ago

@vsasvipul0605 It's been a while since I had this issue, but I think the idea is to delete the lock file and re-run composer install or composer update to get a fresh lock file without the issue

vsasvipul0605 commented 4 years ago

but I told that I can't delete composer.lock file. composer.lock is must needed for heroku deployment

kubawerlos commented 4 years ago

@vsasvipul0605 yes you can :)

I'm deploying on heroku and build starts failing on heroku without composer.lock file

So you can't have composer.lock deleted from your repository.

But you can delete the file, then run composer update and commit the modified composer.lock.

vsasvipul0605 commented 4 years ago

I exactly did the same but travis build error occurring again. Any other alternative solution?

kubawerlos commented 4 years ago

Have you tried Composer's flags --update-with-dependencies and --update-with-all-dependencies?

vsasvipul0605 commented 4 years ago

Where to write these composer flags?

kubawerlos commented 4 years ago

In composer require command.

vsasvipul0605 commented 4 years ago

i dont have composer require in my repo. can u explain in detail. repo details: https://github.com/vsasvipul0605/covid19-india-stats/tree/heroku

kubawerlos commented 4 years ago

Composer the tool itself has this command, see this comment: https://github.com/sebastianbergmann/phpunit/issues/2823#issuecomment-338506914

and use it with packages that make the trouble.

vsasvipul0605 commented 4 years ago

still the same error. i tried this too.