Original issue on Drupal core project #3036459: Packaging info from .info.yml often creates conflicts when patching
Problem/Motivation
Disclaimer: Not sure that is the right project to post this.
- Add a module as dist (using a stable, beta, alpha version) in your composer.json.
- Create a patch that fixes the .info.yml file.
- Add the patch in composer.json and update.
In most of the cases the paching will fail because the content of the dist .info.yml contains also the packager script lines. The patch is build every time using the source, where those lines doesn't exist.
Proposed resolution
The .info.yml file is part of the codebase, it should not be altered by any script.
Long term solution
Move these package info in their own file that should be added by the the packager script, as LICENSE.txt is added.
Quick fix
Before the line # Information added by Drupal.org packaging script on ... add enough empty lines, so that the changed hunk doesn't interfere. Will still be a problem with the .info.yml files of sub-modules being deleted.
Remaining tasks
None.
User interface changes
None.
API changes
None.
Data model changes
None.
Release notes snippet
N/A
Comments
Comment #2
drummThis is the right place for packaging, more newlines could be added at https://git.drupalcode.org/project/drupalorg/blob/dev/drupalorg_project/...
I don’t think any other change is possible without Drupal core knowing to look in another place, and a project requiring at least that version of core. Taking away data update status and other modules depend on isn’t something we can do right away.
Comment #3
MixologicI think the best path forward here is for core to expect data in either the .info.yml files, or in a new .drupalorg.packaging file that can be gitignored, but would have added data in it.
manipulating the metadata files is a throwback to earlier cvs days, and I think we've got better ways to handle this now.
Comment #4
claudiu.cristeaIn a first phase we add data in both, .info.yml and .drupalorg.packaging.yml but we deprecate usage from .info.yml (how?). Then we fix core not to use anymore the packaging data from .info.yml. Probably we won’t be able to remove packaging data from .info.yml sooner than Drupal 9 because some modules might use it.
I don’t think this is blocked by removing .info.yml in favor if composer.json issue as such data should not be injected neither in .info.yml nor in composer.json.
Comment #5
drummPackaging shouldn’t be deleting any .info.yml files. Do you have an example of this happening?
Comment #6
MixologicI think that meant "If the patch deletes a submodule's .info.yml" for whatever reason, it will fail.
Comment #7
joshua.boltz commentedI think this is a real blocker for many composer-based sites moving over to or starting builds out on Drupal 9, because many modules in the community are not yet fully D9 ready. Thanks to tools like Drupal-check, there are many patches getting added and committed to projects to fix the deprecated code issues, but the other part of making a module D9 ready is it having the `core_version_requirement` line in the info.yml file.
Some modules have been providing this already and typically is included in the next major version, or at least in the latest Dev version. When the `core_version_requirement` line is already committed to a stable or dev release, it works fine.
But many modules still are missing this single, one-line change, and could be likely due to the same issue I've come across when attempting to create patches to add `core_version_requirement` to the info.yml file. The issue is that when applying the patch to a Git clone of the project, it works great. But, when the patch is included in composer.json "extra/patches" section, due to things noted in this issue and how package information is added, the patch fails to apply.
In some cases, we have been successful getting a patch to apply, but it feels super hacky with how it had to work because the `core_version_requirement` line was in an odd location in the info.yml, such as above the `description` line. This is due to the rule that there needs to be 3 lines above the diff and 3 lines below the diff, so that the package information can be placed in the info.yml given those lines and locations.
Comment #8
joshua.boltz commentedFYI this is a good example to add context to my previous #7 comment:
https://www.drupal.org/project/videojs/issues/3175575#comment-13852809
You can see there is a patch in that issue to add the `core_version_requirement` line.
But, when i apply that patch via composer patches ("extra/patches") via the composer-patches plugin with Composer:
https://github.com/cweagans/composer-patches
It does not apply cleanly. Here is the .rej file output:
Comment #9
quietone commentedRan into this in Commerce Migrate, #3179943: Can't install on a clean version of 9.0.7 with composer
Comment #10
carolpettirossi commentedRan into this in LayoutBuilder Search API install on Drupal 10. https://www.drupal.org/project/layoutbuilder_search_api/issues/3371584
Comment #11
kartagisI have run into this in multiple occassions, today being the latest incident. I remember having the very same issue a few years ago and drumm fixing it. I think it was drumm.