Closed dnaber-de closed 7 years ago
The issue here is that composer require johnpbloch/wordpress:~4.7.0
doesn't do what it looks like you think it should. It sounds like you'd like it to do this:
Unfortunately, that's not what it does. What it does is it updates the composer.json file and then tries to resolve dependencies without changing anything else in the dependency tree, including dependencies of the package you're updating. So the problem stems from the fact that this package is a meta package that requires an identical version of johnpbloch/wordpress-core
and the core installer. When you try to update from 4.6.6 to 4.7.0, it still wants to keep 4.6.6 of the wordpress-core
package, but the new version of this package says it needs 4.7.0.
You have a few options here:
First, you could edit composer.json
manually, changing "johnpbloch/wordpress": "~4.6.0"
to "johnpbloch/wordpress": "~4.7.0"
, then run composer update
.
Secondly, you could make a slight change to the commands you run:
composer require --no-update johnpbloch/wordpress:~4.7.0
composer update
This option is the same as the option above, but doesn't involve manually editing the composer.json file.
Your last option is to migrate away from this package and replace this:
"johnpbloch/wordpress": "~4.7.0"
with this:
"johnpbloch/wordpress-core": "~4.7.0",
"johnpbloch/wordpress-core-installer": "^1.0"
It sounds like this might not be feasibly right away, since it sounds like some of your other dependencies list johnpbloch/wordpress
. Those would need to list johnpbloch/wordpress-core
instead before you could migrate away from this package.
I should add that the second option I listed is what is recommended by the creator of composer:
https://twitter.com/seldaek/status/851447070393237504 (thread)
Ah, I just learned about an option of which I was heretofore ignorant:
composer require --update-with-dependencies johnpbloch/wordpress:~4.7.0
Should also do the trick.
Confirmed: composer require --update-with-dependencies johnpbloch/wordpress:~4.7.0
works as expected:
tmpwp $ composer require johnpbloch/wordpress:~4.6.0
./composer.json has been created
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 3 installs, 0 updates, 0 removals
- Installing johnpbloch/wordpress-core-installer (0.2.1): Loading from cache
- Installing johnpbloch/wordpress-core (4.6.6): Downloading (100%)
- Installing johnpbloch/wordpress (4.6.6.1): Downloading (100%)
Writing lock file
Generating autoload files
tmpwp $ composer require johnpbloch/wordpress:~4.7.0
./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
- johnpbloch/wordpress 4.7.5 requires johnpbloch/wordpress-core 4.7.5 -> satisfiable by johnpbloch/wordpress-core[4.7.5].
- Conclusion: don't install johnpbloch/wordpress-core 4.7.5
- johnpbloch/wordpress 4.7.4.1 requires johnpbloch/wordpress-core 4.7.4.1 -> satisfiable by johnpbloch/wordpress-core[4.7.4.1].
- Conclusion: don't install johnpbloch/wordpress-core 4.7.4.1
- johnpbloch/wordpress 4.7.4 requires johnpbloch/wordpress-core 4.7.4 -> satisfiable by johnpbloch/wordpress-core[4.7.4].
- Conclusion: don't install johnpbloch/wordpress-core 4.7.4
- johnpbloch/wordpress 4.7.3 requires johnpbloch/wordpress-core 4.7.3 -> satisfiable by johnpbloch/wordpress-core[4.7.3].
- Conclusion: don't install johnpbloch/wordpress-core 4.7.3
- johnpbloch/wordpress 4.7.2 requires johnpbloch/wordpress-core 4.7.2 -> satisfiable by johnpbloch/wordpress-core[4.7.2].
- Conclusion: don't install johnpbloch/wordpress-core 4.7.2
- johnpbloch/wordpress 4.7.1 requires johnpbloch/wordpress-core 4.7.1 -> satisfiable by johnpbloch/wordpress-core[4.7.1].
- Conclusion: don't install johnpbloch/wordpress-core 4.7.1
- Can only install one of: johnpbloch/wordpress-core[4.7.0, 4.6.6].
- Can only install one of: johnpbloch/wordpress-core[4.7.0, 4.6.6].
- Can only install one of: johnpbloch/wordpress-core[4.7.0, 4.6.6].
- johnpbloch/wordpress 4.7.0 requires johnpbloch/wordpress-core 4.7.0 -> satisfiable by johnpbloch/wordpress-core[4.7.0].
- Installation request for johnpbloch/wordpress ~4.7.0 -> satisfiable by johnpbloch/wordpress[4.7.0, 4.7.1, 4.7.2, 4.7.3, 4.7.4, 4.7.4.1, 4.7.5].
- Installation request for johnpbloch/wordpress-core (locked at 4.6.6) -> satisfiable by johnpbloch/wordpress-core[4.6.6].
Installation failed, reverting ./composer.json to its original content.
tmpwp $ composer require --update-with-dependencies johnpbloch/wordpress:~4.7.0
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 0 installs, 2 updates, 0 removals
- Updating johnpbloch/wordpress-core (4.6.6 => 4.7.5): Loading from cache
- Updating johnpbloch/wordpress (4.6.6.1 => 4.7.5): Downloading (100%)
Writing lock file
Generating autoload files
tmpwp $
Thanks a lot, John!
TL;DR You probably want to run
Original issue text:
Since the restructuring of the package I frequently run into issues with composer require or update commands.
If I have for example WordPress installed at 4.6-branch and want to upgrade to 4.7-branch I'd normally do it by the require command:
What I would expect here is, that composer removes the 4.6-package and installs 4.7 instead. Like it does for example with
symfony/console
:Tested composer version is 1.4.2, PHP version is 7.0.21 on Ubunut 14.04
It would not that big issue if I'd only had WP as single package because I could remove and require it manually. But as there are several other packages that requires WordPress, I have to remove all of them in the correct order by hand.