Tried to install Commerce, got a crash, cause drupal/entity isn't installable.

It thinks that drupal/entity is the Entity module that shipped with Drupal core in the early 8.x alphas, instead of the contrib module.
Looks like the idea of exporting core modules as Composer packages won't really work, for example you have the BigPipe module as both a contrib module and a core module (from 8.1)

Full output:

Problem 1
    - drupal/drupal 8.0-alpha7 requires doctrine/common dev-bmaster#99b44f52a1b844f9c4c34e618b160664d5c27daf -> no matching package found.
    - Installation request for drupal/commerce 2.0.x-dev -> satisfiable by drupal/commerce[2.0.x-dev].
    - Conclusion: remove drupal/drupal 8.1.9999999.9999999-dev
    - Conclusion: don't install drupal/drupal 8.1.x-dev
    - drupal/commerce 2.0.x-dev requires drupal/entity * -> satisfiable by drupal/entity[8.0.0-alpha14, 8.0.0-alpha13, 8.0.0-alpha12, 8.0.0-alpha11, 8.0.0-alpha10, 8.0.0-alpha9, 8.0.0-alpha8, 8.0.0-alpha7, 8.0.0-alpha6, 8.0.0-alpha5, 8.0.0-alpha4, 8.0.0-alpha3, 8.0.0-alpha2].
    - drupal/entity 8.0.0-alpha14 requires drupal/drupal 8.0.0-alpha14 -> satisfiable by drupal/drupal[8.0.0-alpha14].
    - drupal/entity 8.0.0-alpha13 requires drupal/drupal 8.0.0-alpha13 -> satisfiable by drupal/drupal[8.0-alpha13].
    - drupal/entity 8.0.0-alpha12 requires drupal/drupal 8.0.0-alpha12 -> satisfiable by drupal/drupal[8.0-alpha12].
    - drupal/entity 8.0.0-alpha11 requires drupal/drupal 8.0.0-alpha11 -> satisfiable by drupal/drupal[8.0-alpha11].
    - drupal/entity 8.0.0-alpha10 requires drupal/drupal 8.0.0-alpha10 -> satisfiable by drupal/drupal[8.0-alpha10].
    - drupal/entity 8.0.0-alpha9 requires drupal/drupal 8.0.0-alpha9 -> satisfiable by drupal/drupal[8.0-alpha9].
    - drupal/entity 8.0.0-alpha8 requires drupal/drupal 8.0.0-alpha8 -> satisfiable by drupal/drupal[8.0-alpha8].
    - drupal/entity 8.0.0-alpha7 requires drupal/drupal 8.0.0-alpha7 -> satisfiable by drupal/drupal[8.0-alpha7].
    - drupal/entity 8.0.0-alpha6 requires drupal/drupal 8.0.0-alpha6 -> satisfiable by drupal/drupal[8.0-alpha6].
    - drupal/entity 8.0.0-alpha5 requires drupal/drupal 8.0.0-alpha5 -> satisfiable by drupal/drupal[8.0-alpha5].
    - drupal/entity 8.0.0-alpha4 requires drupal/drupal 8.0.0-alpha4 -> satisfiable by drupal/drupal[8.0-alpha4].
    - drupal/entity 8.0.0-alpha3 requires drupal/drupal 8.0.0-alpha3 -> satisfiable by drupal/drupal[8.0-alpha3].
    - drupal/entity 8.0.0-alpha2 requires drupal/drupal 8.0.0-alpha2 -> satisfiable by drupal/drupal[8.0-alpha2].
    - Can only install one of: drupal/drupal[8.1.x-dev, 8.0.0-alpha14].
    - Can only install one of: drupal/drupal[8.1.x-dev, 8.0.0-alpha13].
    - Can only install one of: drupal/drupal[8.1.x-dev, 8.0.0-alpha12].
    - Can only install one of: drupal/drupal[8.1.x-dev, 8.0.0-alpha11].
    - Can only install one of: drupal/drupal[8.1.x-dev, 8.0.0-alpha10].
    - Can only install one of: drupal/drupal[8.1.x-dev, 8.0.0-alpha9].
    - Can only install one of: drupal/drupal[8.1.x-dev, 8.0.0-alpha8].
    - Can only install one of: drupal/drupal[8.1.x-dev, 8.0.0-alpha7].
    - Can only install one of: drupal/drupal[8.1.x-dev, 8.0.0-alpha6].
    - Can only install one of: drupal/drupal[8.1.x-dev, 8.0.0-alpha5].
    - Can only install one of: drupal/drupal[8.1.x-dev, 8.0.0-alpha4].
    - Can only install one of: drupal/drupal[8.1.x-dev, 8.0.0-alpha3].
    - Can only install one of: drupal/drupal[8.1.x-dev, 8.0.0-alpha2].
    - Can only install one of: drupal/drupal[8.1.x-dev, 8.0-alpha10].
    - Can only install one of: drupal/drupal[8.1.x-dev, 8.0-alpha11].
    - Can only install one of: drupal/drupal[8.1.x-dev, 8.0-alpha12].
    - Can only install one of: drupal/drupal[8.1.x-dev, 8.0-alpha13].
    - Can only install one of: drupal/drupal[8.1.x-dev, 8.0-alpha2].
    - Can only install one of: drupal/drupal[8.1.x-dev, 8.0-alpha3].
    - Can only install one of: drupal/drupal[8.1.x-dev, 8.0-alpha4].
    - Can only install one of: drupal/drupal[8.1.x-dev, 8.0-alpha5].
    - Can only install one of: drupal/drupal[8.1.x-dev, 8.0-alpha6].
    - Can only install one of: drupal/drupal[8.1.x-dev, 8.0-alpha8].
    - Can only install one of: drupal/drupal[8.1.x-dev, 8.0-alpha9].
    - Can only install one of: drupal/drupal[8.1.x-dev, 8.0.0-alpha14].
    - Installation request for drupal/drupal 8.1.9999999.9999999-dev -> satisfiable by drupal/drupal[8.1.9999999.9999999-dev].
CommentFileSizeAuthor
#7 namespace_collisions.txt13.59 KBMixologic
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

bojanz created an issue. See original summary.

webflo’s picture

Please share the composer.json. thanks!

Mixologic’s picture

This is an artifact of not having namespaces for modules (vs projects which are namespaced) the workaround, which needs to be documented, is that any time a module has the exact same name as another that had already been processed, it namespaces the package name as drupal/<projectname>_<modulename>

So, in this case, you can use require drupal/entity_entity and it will find the entity module from the entity project.

The projects were processed in usage stat order, so that the most popular ones got the shorter name, which gave drupal core priority.

bojanz’s picture

@Mixologic
However, Drupal core hasn't had an entity module for years. The logic makes sense only for current core modules.

@webflo
I used core + "composer require drupal/commerce 2.0.x-dev".

Mixologic’s picture

So additionally, a problem exists where the json generated by project_composer for commerce says drupal/entity, so project_dependency isnt able to accurately determine *which* entity module commerce is dependent upon.

The largest conflict we're going to likely run into with dependencies that have conflicting module names are most likely drupal core modules like bigpipe and entity. So perhaps drupal core modules should be namespaced as core_entity and core_bigpipe.

I'll make this change and see if that helps.

webflo’s picture

We have project namespaces for modules, Drupal Commerce could define entity:entity in its info file. composer info drupal/entity --all should list the versions from the contrib module as well. But it works only if a contrib module does not release version 8. Zen is already at 7 :/

I have to think more about it. It wasn't an issue on Drupal-Packagist because we used replace instead of metapackages, and everything had a dependency to drupal/core (or drupal/drupal).

Mixologic’s picture

FileSize
13.59 KB

Okay, so we have fixed this issue by building a package namespace lookup table as the first step to creating the facade. This ensures that if a project has a dependency on a module, that dependency gets translated to the correct namespace.

Additionally, we are not storing package metadata for drupal core modules (drupal/) as any require for those, or dependency on those should already be fulfilled by drupal/core or drupal/drupal.

For the most part, this is fixed such that module migration either into or out of core itself shouldn't be as big of an issue.

There are still some module namespace collisions, mostly when a big project was split into smaller projects, but the impact is less severe.

Attached is a file of all the known namespace collisions in the map - this info should someday appear on project pages, but its not there yet.

Mixologic’s picture

Note that almost all of those namespace collisions are for d7 modules. there's only about 7 on there that are d8.

Mixologic’s picture

Status: Active » Reviewed & tested by the community
Mixologic’s picture

Status: Reviewed & tested by the community » Needs work

Okay, so I see one other issue here.

There's two ways to specify dependencies, and ideally, they are in sync. Right now, I am relying on whatever is specified in the info.yml file as being a requirement of the module, and ignoring any dependencies specified in the composer.json if they are in the drupal/* namespace - this was to avoid the potential versioning collisions between drupal-packagist and the new in composer.json files (I wouldnt have any way of knowing if you are specifying semver versions or drupal-packagist).

So therefore commerce needs to expand the dependencies it has in the info.yml file to include its other dependencies as well as their constraints in order to allow it to work simultaneously with the drupal-packagist and the composer-facade.

Mixologic’s picture

Turns out commerce was doing things a little bit differently, which also turns out to be a pretty fair use case to support.
We're no longer ignoring the composer.json as of #2746737: Modules with invalid composer.json versions and documentation of this usage is started here: #2754747: Document root composer.json details but should be moved to the docs page.

Mixologic’s picture

Status: Needs work » Needs review

Once I get everything deployed, we'll doublecheck that this works, and closed/fixed it then.

Mixologic’s picture

Status: Needs review » Fixed

This is all deployed now.

Mixologic’s picture

Status: Fixed » Closed (fixed)

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