How to resolve the conflict "You can install only one of:"?

I installed one package through Composer, and it also installed Guzzlehttp because of the package. After that, I tried installing another package through Composer, which also requires Guzzlehttp and Composer to try installing it again.

But I get this error:

Problem 1

  • You can install only one of: guzzlehttp / guzzle [6.2.0, 6.0.2].

  • You can install only one of: guzzlehttp / guzzle [6.0.2, 6.2.0].

  • You can install only one of: guzzlehttp / guzzle [6.0.2, 6.2.0].

I see what the problem is, but I don’t know how to fix it.

+5
source share
2 answers

I had a similar problem and I just needed to run

composer update

before installing a new package. This will work depending on whether other installed packages have updated their dependencies too.

+3
source

"You can install only one message [x, y]", when two different packages point to the same dependency, but different major, mutually exclusive versions, where you can install only one.


Fix problems

For example, one version may be “blocked” due to information in your composer.lock file that may conflict with what you are trying to install. In this case, when a confusion error occurs with the message "locked in xyz", you can use the following commands to understand the existing dependencies of installed packages:

 composer show -t 

Note: -t appears as a nested tree view, discards it to see a flat list.

To find out what the problematic package is referencing in your project:

 composer why org/package -t 

Note: -t appears as a nested tree view, discards it to see a flat list.

To view the details of the package you are trying to install, you can run:

 composer show -a org/package # Package to inspect. 

Note. To check for a specific version, add xyz , for example: composer show -a guzzlehttp/guzzle 6.2.0


To continue troubleshooting, depending on the situation, you can try:

  • Update existing packages with:

     composer update --with-dependencies 
  • Update or remove conflicting dependencies from your composer.json (keep it simple).

  • When the confusion message shows “locked in xyz”, use composer why org/package to see where the package refers (or check the contents of composer.lock manually by looking for xyz ). If this does not help, think about how to remove composer.lock and again -t ry;
  • When you are asked to use composer.json from another folder , select n .
  • Re -t ry is your simple composer.json , simplified configuration in an empty folder.
  • Run composer diagnose to check for any common error.
  • Use -v / -vv / -vvv to increase the verbosity of your commands.
  • See Also: How to explain Composer error log?
+3
source

Source: https://habr.com/ru/post/1247080/


All Articles