Problem/Motivation

If you start a Drupal 8.9.0-beta2 project with Composer like this:

$ composer create-project drupal/recommended-project:8.9.0-beta2 upgradetest
$ cd upgradetest/

... you can update with this command:

$ composer update drupal/core-recommended --with-dependencies
[..]
  - Updating drupal/core (8.9.0-beta2 => 8.9.2): Downloading (100%)         
  - Updating drupal/core-recommended (8.9.0-beta2 => 8.9.2)

However, with Drush installed, it downgrades to 8.8.8:

$ composer require drush/drush
Using version ^10.3 for drush/drush
$ composer update drupal/core-recommended --with-dependencies
Dependency "composer/installers" is also a root requirement, but is not explicitly whitelisted. Ignoring.
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 2 installs, 3 updates, 2 removals
  - Removing laminas/laminas-feed (2.12.0)
  - Removing laminas/laminas-diactoros (1.8.7)
  - Updating laminas/laminas-zendframework-bridge (1.0.1 => 1.0.4): Loading from cache
  - Installing zendframework/zend-feed (2.12.0): Downloading (100%)         
  - Installing zendframework/zend-diactoros (1.8.7): Downloading (100%)         
  - Downgrading drupal/core (8.9.0-beta2 => 8.8.8): Downloading (100%)         
  - Downgrading drupal/core-recommended (8.9.0-beta2 => 8.8.8)
$ 

Original report by @hansfn

Cannot update core with composer.

CommentFileSizeAuthor
composer-update-890beta-892.txt33.69 KBressa

Comments

ressa created an issue. See original summary.

ressa’s picture

Issue summary: View changes
jcnventura’s picture

Issue summary: View changes

This works however: composer update drupal/core-recommended symfony/* --with-all-dependencies

Seems to be some interference between the symfony libraries used by drush and the ones locked down by drupal/core-recommended. It's probably not a good idea to only update drupal/core-recommended without updating the rest (or at least symfony/*), unless the site is a drupal core test. In this case, and at this time, I saw that symfony/polyfill-php72 had to be downgraded from 1.18 to 1.17 to allow the installation of core 8.9.2.

hansfn’s picture

And next time it's some non-Symfony package causing the problem ... I just love Composer.

We need to be able to recommend one command that always works and don't upgrade too much (potentially breaking the site). ressa and I wonder if simply

composer update

is "safe" when you using core-recommended (which you get when starting with recommended-project).

jcnventura’s picture

Yes. composer update should be safe, you'll get the version locks provided by core-recommended, and also allow all packages to adjust to them.

ressa’s picture

Thanks for weighing in @jcnventura, and yes I agree with @hansfn that we should strive to recommend the shortest possible command, to keep it simple. But won't composer update also update any modules with updates? Of course, unless they are pinned with ~2.0 or ^1.2 in composer.json.

@greg.1.anderson mentions testing Drush beforehand in #38 in #3159647: Add drush/drush to Drupal Composer project templates which would at least take care of Drush.

jcnventura’s picture

@ressa, ~ or ^ won't lock your module versios. Only their absence will pin them.. And yes, composer update updates everything.

The issue here was that drush was depending on a package (symfony/polyfill-php72) that was not part of core-recommended upto 8.9.0-beta3. There are probably a few other drush dependencies that are not core dependencies.

The steps above added the latest version of this polyfill to the install, and the subsequent composer update of core-recommended would not complete to later than 8.9.0-beta2 because of this conflict. This does have the potential to happen with any drush dependency that is not shared with core. In this case, updating also all the symfony/* packages fixed it, but it could be one of the other dependencies in the future.

ressa’s picture

Sorry @jcnventura, you are correct, I meant limited in their "span of possible updates", as opposed to pinning it down with "drupal/admin_toolbar": "2.0.0". Thanks for clarifying, and confirming that composer update would also update any modules with updates, except if pinned.

jcnventura’s picture

Status: Active » Closed (works as designed)

Closing this, as there's not much to be done here (at least not without a DeLorean with a flux capacitor), since:

  1. drush depends on symfony/var-dumper 4 since 2018-10-22.
  2. symfony/var-dumper 4 depends on symfony/polyfill-php72 since 2017-10-10
  3. drupal/core-recommended started depending on symfony/polyfill-php72 on 2020-05-09

Obviously any dependency of drush that is not already a dependency of drupal/core-recommended has the potencial to create this same problem in the future. The solution would be to either prevent the use of extra packages by drush, or that drupal/core-recommended not add any new dependencies. None of these are acceptable, so just have to live with it.