Hey there,
Problem/Motivation
i added the new drupal/anchor_link composer.libraries.json to my composer.json. Everything on anchor_links side works as expected but now I am missing ckeditor/fakeobjects and ckeditor/link on webform side. This is due to the reason that webforms composer.libraries.json adjusted the installer name of the installed packages
e.g. for ckeditor/link:
"extra": {
"installer-name": "ckeditor.link"
},In this case Webform is looking for libraries/ckeditor.link but for drupal/anchor_link it is installed as libraries/link.
Steps to reproduce
Just have both composer.libraries.json in your composer.json in this order
"merge-plugin": {
"include": [
"web/modules/contrib/webform/composer.libraries.json",
"web/modules/contrib/anchor_link/composer.libraries.json"
]
},and run
composer update --with-dependencies
Proposed resolution
Following webforms given standard for composer.libraries.json and add the installer-name attribute to make the libraries available to both modules.
edit:
All module paths to the plugins would have to be adjusted, too. This only works with the exception that both modules have to use the same version of the plugin. As far as I know multiple versions of the same package are not supported by composer. I guess this has to be overthinken to get to a clean solution.
| Comment | File | Size | Author |
|---|---|---|---|
| #27 | 3204935-anchor_link-adjust-libraries-27.patch | 5.27 KB | jrsouth |
| #23 | 3204935-anchor_link-adjust-libraries-23.patch | 5.24 KB | nuuou |
| #19 | anchor_link-n3204935-18.patch | 4.95 KB | damienmckenna |
| #16 | 3204935-anchor_link-adjust-libraries-16.patch | 5.02 KB | smustgrave |
Issue fork anchor_link-3204935
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
r81d3r commentedComment #5
jurgenhaasComment #6
smustgrave commentedThis would be fantastic! Sucks having to have 2 copies of the same library!
Comment #7
smustgrave commentedSo I added the patches and the line to my composer-merge-plugin. Now when I run composer update the libraries are being changed back to link or fakeobjects. Because of the order.
So with the patches they can't find the libraries again because it's looking for ckeditor.link. Should
"extra": {
"installer-name": "ckeditor.link"
},
be added to these modules too?Take that back that must be added. If it's not and you aren't using webform then this module is now broken because it would be looking for ckeditor.link but this libraries.yml file will load it as link.
Comment #8
jurgenhaas@smustgrave that's a great idea, I've added that to the merge request.
Note, it didn't break here, because I've added the installer name config to the root project's composer.json where you have to declare the repository. But still, better doing this at the source.
Comment #9
smustgrave commentedSo still causing issues with me. I think the install-name needs to be in the composer.libraries.json file. If someone calls the anchor_links composer.libraries it will install the libraries under link and fakeobjects.
Comment #10
jurgenhaasThat's an additional issue maybe, I don't see why and when that should be required. When you use
composer installon the root project, it will only look into the composer.json of the module and install the module together with the library. If something was wrong, e.g. the repo not defined in the root composer.json, it won't install the module in the first place.I don't think that for a composer based workflow, any other scenario could happen. It either installs the module, then the lib gets installed to, or it doesn't.
For a non-composer based workflow - which by all means is no longer recommended - I struggle to see why somebody wanted to use composer for a library installation of a sub-module.
Or is there any other mean to the composer.libraries.json file that I'm missing?
Comment #11
smustgrave commentedIf you add
"merge-plugin": {
"include": [
"web/modules/contrib/webform/composer.libraries.json",
"web/modules/contrib/anchor_link/composer.libraries.json"
]
},
It will pull the libraries in the wrong directories. If I clear my root/libraries folder and do a fresh install it still doesn't pull in the right. Same if I delete the anchor_link module and run composer install. I believe this approach is saying you shouldn't use composer.libraries and that using it could break the module.
Comment #12
jurgenhaasThe merge plugin got abandoned from Drupal core quite a while ago. We still "liked" it and wanted to continue using it, but since it doesn't support Composer 2, we've had to remove it completely. And TBH, the issues it causes have been much bigger than its benefits. So, I wouldn't recommend using it any longer, but of course if the maintainers of this module want to continue maintaining the composer.libraries.json file, it is pretty easy to add that extra line there too.
Comment #13
smustgrave commentedSo composer merge plugin 2.0.x does work with Composer 2 now.
And this ticket seemed to be about getting other modules to follow the standard that webform appears to be using with the ckeditor. prefix. They add their installer-name in the composer.libraries file and not composer.json. So that's kind of why I think it should be moved here to match. So everything is following the same pattern and working together.
Comment #14
smustgrave commentedHere's a patch that if you call composer.libraries it will load the libraries into ckeditor.link and ckeditor.fakeobjects.
Comment #16
smustgrave commentedOops wrong file
Comment #17
jurgenhaas@smustgrave adding your extra changes to the MR might be easier for the maintainers to review and eventually merge.
Comment #19
damienmckennaA slight improvement on whitespace in composer.libraries.json. I also updated the MR with the changes from #16.
Comment #20
mingsongI think the solution suggested by #3118314: drupal-ckeditor-libraries-group composer installation support is easier which doesn't require any modification to the root composer.json file.
Comment #21
volegerComment #22
damienmckennaHaving looked through it, I think it'd be worth supporting the library from both locations, but that the module should default to reusing the same path as Webform uses.
Changing the status back to "needs work" as both paths should be supported.
Comment #23
nuuou commentedRe-roll of #19 from above against 8.x-2.x-dev.
8.x-2.6 just released a few days ago, so patch was incompatible. Also took care of a couple typos while I was in there.
I agree with #22 that ideally both would be supported in some capacity!
Comment #24
rajab natshahI agree with #22 too
Testing the changes
Comment #25
jcnventuraTo be honest, it makes no sense that this module is providing the library for CKEditor FakeObjects. The composer json of this module should restrict itself to the ckeditor.link plugin, since that is the one it uses directly, even if the fakeobjects plugin must also be installed somehow, but that should be handled by that module. See #3208959: Store plugin in libraries/ckeditor.fakeobjects.
Comment #26
jurgenhaas@jcnventura is this maybe worth a separate issue? I mean, the fakeobject has been in the code base also before this discussion about the library location started, which is what this issue is about, isn't it?
Comment #27
jrsouth commentedTweak to the patch in #23
Missed one instance of
>linkckeditor.linkwhich was causing the library to be found in the filesystem at the new location, but was still reporting the original location.Comment #28
jcnventuraIndeed, totally agree with @jurgenhaas on #26.
In the meantime, tested #27 and all seems working as expected.
Comment #29
agentrickardBumping. Still works in conjunction with #3208959: Store plugin in libraries/ckeditor.fakeobjects
Comment #30
pfrenssenStarting with Webform 6.2.0, the Webform module is no longer offering their own version of CKEditor but has switched to core's editor. This was done so they could support both CKEditor 4 and 5 without having to maintain their own custom versions of both. They have now switched to offering their own editor profiles instead. For more info see #3322552: CKEditor 5 support.
That means changing the install paths to match Webform's naming scheme is not a good idea any more, since these are only used in Webform 6.1.x which will be obsolete in 2 weeks when Drupal 9 support is dropped.
I propose to close this as "Won't fix".
Comment #31
pfrenssen