Incorrect version of CKEditor being parsed from info.yml files

Created on 15 September 2022, almost 2 years ago
Updated 20 October 2023, 8 months ago

Problem/Motivation

The D7 CKEditor 4 - WYSIWYG HTML editor project has just released a 1.0.1 version that is compatible with Drupal 9 and 10. Since this has been released, any module that lists a dependency on the core drupal:ckeditor in its info.yml file is causing the contrib ckeditor project to be required by composer, even if it doesn't list it as a dependency in a composer.json file.

I assume that the Drupal composer repository is doing something with .info.yml dependencies, but it is incorrectly parsing the dependencies: Core's CK Editor module is drupal:ckeditor and the contrib project would be correctly added as ckeditor:ckeditor.

I notice that this has started happening since Ensure that ckeditor does not get special core treatment was resolved: has the change made there been implemented to correctly identify when a module requires drupal:ckeditor and ckeditor:ckeditor?

Steps to reproduce

On a clean install, run

composer require drupal/ckeditor_find

Composer will attempt to find an installable set of packages that includes the CKEditor 4 - WYSIWYG HTML editor module despite this not being a dependency.

Solution/Work-around

Per @frob in #24, with clarification by @DamienMcKenna in 28

Update composer.json with:

    "replace": {
        "drupal/ckeditor": "self.version",
        "drupal/color": "self.version"
    },

Per the Composer docs, this should be added at the same level as "repositories" and "require",

🐛 Bug report
Status

Active

Version

1.0

Component

Code

Created by

🇬🇧United Kingdom MrDaleSmith

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇺🇸United States Dave Reid Nebraska 🇺🇸

    This is going to pop up again with the new sdc module that was added to Drupal 10.1, while it exists in contrib for D9/D10.0:
    https://www.drupal.org/project/drupal/issues/3340712#comment-15015670 Add Single Directory Components as a new experimental module Fixed
    https://www.drupal.org/project/sdc

    Anyone who declares a dependency on drupal:sdc in their .info.yml files going forward will unexpectedly get the contrib module. We really need this solved.

  • 🇧🇪Belgium Wim Leers Ghent 🇧🇪🇪🇺

    @Dave Reid: hah, you beat me to it, I was about to post the same! 😊

  • 🇺🇸United States drumm NY, US

    We've mentioned that projects need their name changed as they go into core to avoid conflicts. Since it does happen, we do have some handling of this around project_composer_get_core_modules() https://git.drupalcode.org/project/project_composer/-/blob/62ac7f27f70fd...

  • 🇬🇧United Kingdom MrDaleSmith

    I still think it's a confusing Drupalism to be parsing composer dependencies from the info.yml files. Composer handles dependencies and where they should be downloaded from really well and all our documentation says "Use composer to manage your dependencies". It just causes issues to say "Drupal uses composer to manage dependencies, kind of - sometimes we think it's best to ignore it and use something else".

  • 🇧🇪Belgium Wim Leers Ghent 🇧🇪🇪🇺

    #36: ahh, right! Sorry about that.

    And that is also why this is impossible to solve for CKEditor 4: it lived in core, and to ensure a smooth transition to those sticking to CKEditor 4 for now in Drupal 10, it must have the same name.

    #37: I think everybody agrees with you on that. But Drupal predates Composer by literally more than a decade. So I think it's understandable that we have to slowly evolve, to bring the entire ecosystem along 😊 You're absolutely right it's confusing though!

  • 🇬🇧United Kingdom MrDaleSmith

    We've had a fair amount of time to get used to it, though, where we didn't with other changes like namespacing and plugins. I'd be interested to find out how many projects on d.org have dependencies in their info.yml files that aren't in their composer.json files - can it really be that big a number given that we never told anyone we'd use info.yml for composer dependencies?

  • 🇺🇸United States joshuami Portland, OR

    I'm trying to help a couple clients through their CKEditor 5/Drupal 10 upgrades and have come to the conclusion there are two paths:

    Option 1: While on Drupal 9, upgrade to CKeditor 5, then upgrade to Drupal 10.

    Option 2: Upgrade to Drupal 10 using the contrib ckeditor module, then upgrade to CKEditor 5 at a later date.

    Either option is going to require some custom work to replace functionality from CKEditor 4 contrib modules (ckeditor_acr 1.0.1, ckedtior_config 8.x-3.1), some custom CKEditor 4 widgets (for inserting a phone number, email address, columns, accordions), and some code that relied on the MediaEmbedDialogue form and the ability to edit a media item inline and change attributes.

    Of the two approaches, I would prefer option 2. Upgrading core to Drupal 10 is a larger risk. The smaller risk of not having our CKEditor 4 functionality replicated is not ideal—replicating the functionality is a fair bit of work—but at least it would *just* be CKEditor.

    I was just about to post that there does not seem to be a valid way to add the contrib ckeditor to the latest Drupal 9 release, but then I happened on a successful order of operations.

    Running composer remove drupal/ckeditor_acr or composer remove drupal/ckeditor_config gives me an error like ckeditor_acr is not required in your composer.json and has not been removed.

    If I manually remove ckeditor_acr and ckeditor_config from my composer.json, and run composer update --lock, the files for those two modules are removed. When I then try to composer require drupal/ckeditor:'^1.0', it adds the dependency to the composer.json file, but not to the composer.lock file. A new composer install gives the error:

    - Required package "drupal/ckeditor" is not present in the lock file.
    This usually happens when composer files are incorrectly merged or the composer.json file is manually edited.
    Read more about correctly resolving merge conflicts https://getcomposer.org/doc/articles/resolving-merge-conflicts.md
    and prefer using the "require" command over editing the composer.json file directly https://getcomposer.org/doc/03-cli.md#require-r
    

    It turns out that I also needed, to remove the following:

      "provide": {
        "drupal/ckeditor": "*"
      },
    

    This snippet was recommended in 3309026 to stop ckeditor_config's requirement of drupal/ckeditor from downloading the contrib module unexpectedly. I was able to require, enable, and reconfigure ckeditor_acr and ckeditor_config after successfully switching to the CKEditor 4 contrib module.

    If anyone has a simpler upgrade path, please share. If anyone thinks this comment belongs in another queue, let me know.

  • 🇧🇪Belgium Wim Leers Ghent 🇧🇪🇪🇺

    #40: RE options 1 & 2: that's also documented in the change record , and the deprecated & obsolete modules handbook page . I 💯% agree that that is not enough though. I've been unsuccessful at convincing core committers that #3304736-43: Provide a good UX to ensure the CKEditor 4 to 5 update is always done before upgrading to Drupal 10 unless the contrib module is installed would have made all this much clearer. 😞 Could you please post a similar comment there? 🙏😊

  • 🇺🇸United States joshuami Portland, OR

    Thanks, Wim. I posted a comment (and a comment on my comment). I appreciate the link to the specific CKEditor 5 change record .

    Sheepishly, I have to admit that I'm not good at following change records—there are just so many of them.

    I read release notes—though not all as I don't tend to read the release notes for a branch I'm not currently using. I like xjm's suggestion to include some reference to these known issues in release notes and to the Drupal 10 upgrade handbook .

    Incidentally, I could only find that handbook by searching, it might make sense to include references to that upgrade process in the next few release notes as well. Upgrade instructions are more important information than linking to the release cycle. (Or at the very least the release cycle should link to those upgrade instructions.)

    In the update contributed projects section of that handbook, it makes it sound like upgraded modules will just be compatible, but I've found several modules that have a version compatible with Drupal 9 or Drupal 10 but not both. I feel like we might need a bit of documentation to help module maintainers understand that it is best practice to have a release that is compatible with both major versions at each end of life transition to aid in the upgrade process.

    Maybe we could add a bit to the Drupal 9 compatibility section of the add a composer.json file page in the creating modules handbook .

  • 🇺🇸United States Dave Reid Nebraska 🇺🇸

    FYI as of today we are now getting the https://www.drupal.org/project/ckeditor_lts project installed instead of https://www.drupal.org/project/ckeditor because of the module name is ckeditor_lts is actually "ckeditor". This problem has continued.

  • 🇺🇸United States markfien

    Our upgrade from 9.5 to 10.1 has been disastrous as it relates to CKEditor 5.

    Will the commit resolve this issue:

    The "ckeditor" plugin does not exist. Valid plugin IDs for Drupal\editor\Plugin\EditorManager are: ckeditor5

    or this which we get everytime we try to access anything to edit
    .. throw new PluginNotFoundException($plugin_id, sprintf('The "%s" plugin does not exist. Valid plugin IDs for %s are: %s', $plugin_id, static::class, $valid_ids));

    TIA, Mark

  • 🇺🇸United States cilefen

    @markfien Did you install the contributed drupal/ckeditor on that site? You must if you did not convert to CKEditor 5.

Production build 0.69.0 2024