-1

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

2 Answers 2

2

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

0

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.

4
  • 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. May 5 at 15:41
  • 1
    Is cweagans/composer-patches installed at all? I don't see it in your composer.json.
    – cilefen
    May 5 at 15:51
  • Go nuclear: composer remove drupal/codesnippet; composer require drupal/codesnippet
    – Clive
    May 5 at 15:51
  • 2
    composer why cweagans/composer-patches. If it says it's not installed, apply palm to forehead and delete this question :)
    – Clive
    May 5 at 15:55

Not the answer you're looking for? Browse other questions tagged or ask your own question.