-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Description
Hi!
Apologies if an issue exists or if this has been discussed - I couldn't find an issue immediately.
Suppose there are 2 packages:
- A)
acme/foo
, which requirestransitive/dependency: "^1 | ^2
- B)
acme/bar
, which requirestransitive/dependency: "^1
The problem:
# this WORKS - transitive/dependency 1 is downloaded
composer require acme/bar
composer require acme/foo
# this BREAKS. The first command installs and locks transitive/dependency at v2
# then, the second command fails because transitive/dependency v2 is locked and
# acme/bar only works with v1
composer require acme/foo
composer require acme/bar
In theory (because transitive/dependency
is not a root requirement), Composer could notice that, while acme/bar
doesn't work with v2, that dependency could be downgraded to v1 to satisfy all packages. That "should" (with huge air-quotes) be safe, as it's just a transitive dependency. However, if we're worried that users might be inadvertently using the dependency directly, and this could break things, we could (instead) issue a clear warning on how to fix this:
acme/bar requires transitive/dependency ^1, but version 2.0.0 is locked. However,
your project is compatible with transitive/dependency ^1 and it could be downgraded.
Re-run the command with--allow-major-downgrades
to allow this dependency to
be downgraded.
(This invents a new --allow-major-downgrades
flag).
I'm sure this shouldn't be done in v1, but is it possible for v2?
Activity
Dropping doctrine/inflector v2 support temporarily
feature #611 Dropping doctrine/inflector v2 support temporarily (weav…
Seldaek commentedon May 19, 2020
The error reporting in v2 handles this better to suggest you a way out. I tweaked things so it covers more cases. So now you'd see this in your case:
I think/hope that's clear enough :)
naderman commentedon May 19, 2020
@Seldaek In that error message I find it confusing that it says "is fixed to 2.0.0 (lock file version) by a partial update", what partial update? Should we change the message if it's the require command?
We could generally improve this a little bit by changing the require output to:
Seldaek commentedon May 19, 2020
I like the last suggestion, because special casing the error message based on it being a require/remove command sounds horrible :) I'll try and implement that.
Add output to remove/require command to highlight the fact it is runn…
weaverryan commentedon May 19, 2020
This looks much better - thank you!
stof commentedon May 19, 2020
@Seldaek should
composer install
without a lock file also include some output saying it will actually run an update ?naderman commentedon May 19, 2020
@stof Doesn't it already in v2?
Seldaek commentedon May 19, 2020
yes it does
feature #611 Dropping doctrine/inflector v2 support temporarily (weav…