Trying to install a module with a core dependency (drupal/image_url_formatter depends on drupal/image, drupal/address on drupal/field) fails if Drupal core doesn't contain the .git directory. Without the .git repository the composer-merge-plugin can't guess the version of drupal/core, causing dependency resolution to fail.

Classifying this as a major bug since it makes Composer unusable for anyone using Drupal from a tarball.

webflo has fixed this bug in https://github.com/wikimedia/composer-merge-plugin/pull/102, and the merge-plugin maintainers have tagged v1.3.1 for us.
We now need to update core to use it.
#1475510: Remove external dependencies from the core repo and let Composer manage the dependencies instead might happen in the meantime, but that still leaves us 8.0 to fix.

Steps to reproduce

  1. Create new drupal project using composer: composer create-project drupal/drupal my-project 8.0.*@dev
  2. Add drupal packagist:
    "repositories": [
        {
          "type": "composer",
          "url": "https://packagist.drupal-composer.org"
        }
      ]
    
  3. Require Image url formatter module: composer require drupal/image_url_formatter 8.1.*

Your requirements could not be resolved to an installable set of packages.

Problem 1
- drupal/image_url_formatter 8.1.x-dev requires drupal/image 8.* -> satisfiable by drupal/core[8.0.0, 8.0.0-beta12, 8.0.0-beta13, 8.0.0-beta14, 8.0.0-beta15, 8.0.0-beta16, 8.0.0-rc1, 8.0.0-rc2, 8.0.0-rc3, 8.0.0-rc4, 8.0.1, 8.0.x-dev].
- don't install drupal/core 8.0.x-dev|remove drupal/drupal No version set (parsed as 1.0.0)
- Installation request for drupal/drupal No version set (parsed as 1.0.0) -> satisfiable by drupal/drupal[No version set (parsed as 1.0.0)].

Comments

SiliconMind created an issue. See original summary.

siliconmind’s picture

Issue summary: View changes
bojanz’s picture

This is a composer-merge-plugin bug that occurs only for people who installed Drupal via the tarball.
Composer tries to detect the version of the root package instead of the core package, leading to the fail.

(Composer detects versions properly when there's a git checkout, hence the tarball-only bug).

siliconmind’s picture

@bojanz, in this case Drupal was installed via composer. Don't you think that it's a bit stupid, that drupal installed via composer is unmanageable through the same composer?

bojanz’s picture

@SiliconMind
There are no smart bugs.

You probably answered Y to cleaning up the .git directories at the end of the Composer install/update. Hence the "can't detect version" problem.

siliconmind’s picture

@bojanz

You probably answered Y to cleaning up the .git directories at the end of the Composer install/update.

Of course I did. I needed to set up my own repo there.

peterpoe’s picture

I tried to manually add the version ("version": "8.0.5") but I get this weird error:
Package is not installed: drupal/drupal-8.0.5.0
If I add "version": "8.0.x-dev" the error gets even weirder:
Package is not installed: drupal/drupal-8.0.9999999.9999999-dev

bojanz’s picture

This is the PR that needs to land into merge plugin: https://github.com/wikimedia/composer-merge-plugin/pull/102

After that we need to update merge plugin in core.

EDIT: PR landed, confirmed that the issue is gone. Waiting for merge-plugin 1.3.1 to be tagged.

bojanz’s picture

Version: 8.0.x-dev » 8.1.x-dev
Priority: Normal » Major
Issue summary: View changes

merge-plugin v1.3.1 was tagged, time to update core.

bojanz’s picture

Status: Active » Needs review
StatusFileSize
new9.03 KB
webflo’s picture

Status: Needs review » Reviewed & tested by the community

Confirmed that is works with 8.[0|1].x and composer manager.

bojanz’s picture

Version: 8.1.x-dev » 8.0.x-dev
webflo’s picture

We should update the lockfile in 8.2.x and 8.1.x

bojanz’s picture

Status: Reviewed & tested by the community » Needs work

Bah.

bojanz’s picture

Status: Needs work » Reviewed & tested by the community

Let's continue and fix this in 8.0.x

I am guessing 8.1 will want to update the versions in composer.lock before the next release anyone (and we can do it for all requirements at once).

catch’s picture

Version: 8.0.x-dev » 8.1.x-dev
Status: Reviewed & tested by the community » Needs work

Sorry we should have an 8.2.x/8.1.x patch here as well as the 8.0.x one and fix all three branches at once. As far as I know there's no existing issue to update all requirements in 8.1.x so no guarantee it'll get done otherwise.

webflo’s picture

Status: Needs work » Needs review
StatusFileSize
new1.4 KB
bojanz’s picture

Status: Needs review » Reviewed & tested by the community

Okay, here we go. Thanks, webflo.

alexpott’s picture

Version: 8.1.x-dev » 8.0.x-dev
Status: Reviewed & tested by the community » Patch (to be ported)

Committed d974d55 and pushed to 8.1.x and 8.2.x. Thanks!

I tried to apply #10 to 8.0.x but it failed.

bojanz’s picture

Status: Patch (to be ported) » Reviewed & tested by the community
StatusFileSize
new9.04 KB

Hm, it applied for me, though with some pretty big offsets. Here's a reroll.

  • alexpott committed 0f0c2c3 on 8.2.x
    Issue #2638856 by bojanz, webflo, SiliconMind: Unable to install modules...

  • alexpott committed d974d55 on 8.1.x
    Issue #2638856 by bojanz, webflo, SiliconMind: Unable to install modules...
alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Committed 71dbd0c and pushed to 8.0.x. Thanks!

  • alexpott committed 71dbd0c on 8.0.x
    Issue #2638856 by bojanz, webflo, SiliconMind: Unable to install modules...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

xano’s picture

Shouldn't this have updated composer.json as well to require wikimedia/composer-merge-plugin:~1.3||>=1.3.1? The current solution still allows developers to accidentally specify 1.3.0, perhaps as a left-over from an existing Drupal 8 site, and by doing so to re-introduce the bug.

sprite’s picture

Just observed this composer drupal bug while trying to update a Drupal 8 install:

---

Problem 1
- Installation request for drupal/drupal No version set (parsed as 1.0.0) -> satisfiable by drupal/drupal[No version set (parsed as 1.0.0)].
- drupal-composer/drupal-project 8.x-dev conflicts with drupal/drupal[No version set (parsed as 1.0.0)].
- Installation request for drupal-composer/drupal-project ~8.2 -> satisfiable by drupal-composer/drupal-project[8.x-dev].

---

Although there are posts about patches above, can somone please explain the root cause of the problem and provide a roadmap for fixing it in a buggy installation?

bojanz’s picture

@sprite
Something is wrong in your composer.json, you appear to have both drupal/drupal and drupal-composer/drupal-project in there, they are competing project templates.
You should open a new support request and paste your composer.json there.

kamalpreet singh’s picture

Facing the Same Error.
I don't know What is the matter with Composer. I want to run Cart on the Drupal , So I Installed Commerce Module. For Installing Commerce Module, had to install other 3-4 required modules. ie Ctools 1.9, Views 3.13, Entity API 1.7, Rules 2.9, and Address field 1.2.
There are lots of Dependencies. Even If I don't want to use Composer, Is there any Alternate way ?

Lack of Documentation in Drupal.