Problem/Motivation
I am building a module suite that contains a few independent components in one main repo: Operations (https://www.drupal.org/project/operations/)
The submodules are designed to be installed independently so I created secondary projects for them:
I wasn't aware that pushing submodules would create pseudo-packages on drupal packagist.
When I made the first release in the main project (Operations), and created releases in the secondary project, I learned that Drupal Packagist will create new drupal/* packages from all the drupal modules finds in your project and that if another project comes along with the same namespace, it will avoid collisions by doubling up the name.
Drupal packagist scanned my main "operations" repo and created subpackages based on the composer.json.
- drupal/site
- drupal/site_manager
This poses a problem because I want users to be able to require site and site_manager without the entire operations module code. When you require drupal/site, drupal/operations is included. Drupal Packagist assumed the submodules Site and Site Manager are dependent on on main Operations package when they are not. (My guess is this is so that when you require submodule, since it's code lives in the parent, it says it requires the parent so that code is downloaded?)
Steps to reproduce
# Current result:
$ composer info drupal/site -a
homepage : https://www.drupal.org/project/operations
$ composer info drupal/site-site -a
homepage : https://www.drupal.org/project/site
$ composer info drupal/site_manager -a
homepage : https://www.drupal.org/project/operations
$ composer info drupal/site_manager-site_manager -a
homepage : https://www.drupal.org/project/site
# Desired result:
$ composer info drupal/site -a
homepage : https://www.drupal.org/project/site
$ composer info drupal/site_manager -a
homepage : https://www.drupal.org/project/site_manager
Another strange side effect is there seems to be two drupal/operations packages, with two different descriptions:
❯ composer search operations
Info from https://repo.packagist.org: #StandWithUkraine
drupal/operations Tools for operating Drupal sites.
sebastian/resource-operations Provides a list of PHP built-in functions that operate on resources
drupal/operations Provides tools for operating Drupal sites.
Proposed resolution
Can we change the package names so they point to the drupal projects?
- drupal/site => https://www.drupal.org/project/site
- drupal/site_manager => https://www.drupal.org/project/site_manager
Thanks!
Comments
Comment #2
jon pughComment #3
rajab natshahFacing the same issue at #3338855: Inconsistent extension module machine name (doubled for composer)
Comment #4
jon pughComment #5
jon pughI've removed the submodule from the parent project, operations.
Now drupal/site points to an old version that won't be updated.
Is it even possible to switch this around?
Comment #6
jon pughMoving to Infrastructure queues.
Forgive me if this is not possible, I'm not sure how everything works. I don't even know if these things are editable.
Could we leave the existing Packagist releases the way they are, but change the source module for the next releases?
What would happen if we did this:
Would those new releases get published as the newer versions of drupal/site etc?
Comment #7
jon pughFYI, I have requested to change Operations to a general project. Does this affect how composer packaging works?
https://www.drupal.org/project/infrastructure/issues/3377494
Comment #8
jon pughDigging through the code, I found the place where it creates the double package name:
https://git.drupalcode.org/project/project_composer/-/blob/7.x-1.x/proje...
Looks like the only time
project_composer_namespace_mapgets updated or deleted, it looks for duplicates fromDoes this mean that the only solution here is to delete rows manually from
project_composer_namespace_map?Is that possible?
I think if this was run, then I created new releases for the submodules, it would create a new mapping for those projects?
DELETE FROM {project_composer_namespace_map} WHERE project_nid = 3366014;
Comment #9
drummpackages.drupal.org was the correct queue for requesting namespace switches from what is working as designed. Composer namespaces do not necessarily match project names.
#3304661: Change how modules and submodule dependencies are handled to have more consistent namepsaces [DRAFT]. would be the general change to the current behavior.
Comment #10
jon pughHashing out options...
For reference:
'project_component_category' => ['project_name', 'component_name', 'category'], ),
My guess at the existing records:
Proposed Solution
Update package_namespace based on project_name.
Since package_namespace is not unique, do we have to DELETE records for project_name = 'operations' at all?
I see, it still looks up existing package 'drupal/x', so they would have to be deleted.
Comment #11
drummComment #12
drummSince this involves correcting the project types, #3377494: Change Operations to General Project, this is more about correcting the composer metadata to match the correct project types than changing by-design behavior seen in #3338855: Inconsistent extension module machine name (doubled for composer).
The basic work is done, I did use the queries as-is, along with deleting the data for operations. This allowed https://packagist.org/packages/drupal/operations to be created.