Issue
I'm regularly told by composer that it can't install some kind of package, because it(s dependencies) conflict with something that I already have installed. Often I can't make heads or tails of the conflict, but when it happened again today I looked into it and I saw that there was no real conflict at all.
I wanted to install a package and composer said that the package I wanted depends on doctrine/inflector
at version 1.4
or higher, but that I already have doctrine/inflector
installed and locked at 1.3.1
.
I looked into it, and I never required doctrine/inflector
explicitly. So it's not a direct dependency of my app, but instead it was installed as a dependency of two of my dependencies. Those two dependencies said they needed doctrine/inflector
at versions ^1.2
and ^1.0
respectively. (I found that information in my composer.lock
file.)
So now I don't see why composer is making a fuss. Yes composer chose to install doctrine/inflector
at 1.3.1
in the past to meet the requirements, but there should be no conflict whatsoever if composer just updates the 1.3.1
version it installed in the past to 1.4.1
. But it doesn't do that and instead complains about a conflict.
I now solved the conflict manually by running these commands:
$ composer require doctrine/inflector:1.4.1
$ composer require illuminate/support
$ composer remove doctrine/inflector
I used doctrine remove
, because I don't want to have doctrine/inflector
in my composer.json
.
So sure, this worked, but is there a way to configure composer such that it tries to solve these conflicts on its own? Because I'm sure there are more complicated scenarios where I wouldn't be able to figure out what to do, but composer possibly could if it would just try.
I did some searching on this site and found that composer update
could've helped me maybe, but then I'm still curious to know if there's a better alternative. You see I'm looking for a method where I don't need to know which packages need updating (and where I don't need to necessarily update all my packages either).
Solution
You can achieve with composer require
this using these flags:
$ composer require --help | grep update-with
--update-with-dependencies Allows inherited dependencies to be updated, except those that are root requirements.
--update-with-all-dependencies Allows all inherited dependencies to be updated, including those that are root requirements.
Answered By - kuba
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.