Score:-1

Why is cweagans/composer-patches not installing this patch?

id flag

I'm trying to apply different patches but after the command composer install nothing happens. Output:

Installing dependencies from the lock file (including require-dev)
Verifying lock file contents can be installed on current platform.
Warning: The lock file is not up to date with the latest changes in composer.json. You may be getting outdated dependencies. It is recommended that you run `composer update` or `composer update <package name>`.
Nothing to install, update or remove
Generating autoload files
42 packages you are using are looking for funding.
Use the `composer fund` command to find out more!
  * Homepage: https://www.drupal.org/project/drupal
  * Support:
    * docs: https://www.drupal.org/docs/user_guide/en/index.html
    * chat: https://www.drupal.org/node/314178

For example: I'm trying to apply a patch in my code for the module CKEditor CodeSnippet: https://www.drupal.org/project/codesnippet/issues/3269387

part of the composer.json:

{
    "name": "drupal/recommended-project",
    // some code
    "repositories": [
        {
            "type": "composer",
            "url": "https://packages.drupal.org/8"
        }
    ],
    "require": {
        "composer/installers": "^2.0",
        "drupal/admin_toolbar": "^3.3",
        "drupal/codesnippet": "^1.8",
        "drupal/core-composer-scaffold": "^10.0",
        "drupal/core-project-message": "^10.0",
        "drupal/core-recommended": "^10.0",
        // some code
    },
    // some code
    "config": {},
    "extra": {
        "patches": {
            "drupal/codesnippet": {
                "https://www.drupal.org/i/3269387 - Drupal 10 & CKEditor 5 support": "https://www.drupal.org/files/issues/2023-04-27/3356929-2_0.patch"
            }
        },
        "drupal-scaffold": {
            "locations": {
                "web-root": "web/"
            }
        },
    // some code

Also for testing, I found some patch for the admin toolbar module and tried to apply it but it also doesn't apply

Score:2
id flag

The problem was that cweagans/composer-patches was not installed. After I wrote the command composer require cweagans/composer-patches the patches are now applied after the command composer install

Score:0
id flag

It think this is because:

Warning: The lock file is not up to date with the latest changes in composer.json. You may be getting outdated dependencies. It is recommended that you run composer update or composer update <package name>. Nothing to install, update or remove

That means the package has already been installed in that codebase in the desired version. Because of that you actually have to tell Composer to re-install the package so that the patch will be applied.

Do what it says: composer update drupal/codesnippet

An upcoming version of cweagans/composer-patches will have a composer sub-command that allows re-patching.

bimsalrobit avatar
id flag
I wrote a command. `composer update drupal/codesnippet` and got: "Nothing to modify in lock file" and "Nothing to install, update or remove". Also for testing, I found some patch for the admin toolbar module and tried to apply it but it also doesn't apply.
id flag
Is cweagans/composer-patches installed at all? I don't see it in your composer.json.
cn flag
Go nuclear: `composer remove drupal/codesnippet; composer require drupal/codesnippet`
cn flag
`composer why cweagans/composer-patches`. If it says it's not installed, apply palm to forehead and delete this question :)
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.