Skip to content

Create and copy the "patches" directory by default? #162

@quicksketch

Description

@quicksketch

First time Lagoon user here. When converting our project to Lagoon, ran into the problem whenever building the containers that composer-patches was not able to apply my patches. I would get the following error during composer install:

#8 8.571   - Applying patches for drupal/core
#8 8.571     patches/upstream/core-empty-sections-3065418-28.patch (Issue #3065418: Empty sections render in Layout Builder - these need to be removed.)
#8 8.572 
#8 8.573 In RemoteFilesystem.php line 105:
#8 8.573                                                                                
#8 8.573   [TypeError]                                                                  
#8 8.573   Composer\Util\RemoteFilesystem::copy(): Argument #1 ($originUrl) must be of  
#8 8.573    type string, null given, called in /app/vendor/cweagans/composer-patches/s  
#8 8.573   rc/Patches.php on line 388                                                   
#8 8.573                                                                                
#8 8.573 
#8 8.573 Exception trace:
#8 8.573   at phar:///usr/local/bin/composer/src/Composer/Util/RemoteFilesystem.php:105
#8 8.573  Composer\Util\RemoteFilesystem->copy() at /app/vendor/cweagans/composer-patches/src/Patches.php:388
#8 8.573  cweagans\Composer\Patches->getAndApplyPatch() at /app/vendor/cweagans/composer-patches/src/Patches.php:324
#8 8.573  cweagans\Composer\Patches->postInstall() at phar:///usr/local/bin/composer/src/Composer/EventDispatcher/EventDispatcher.php:228
#8 8.573  Composer\EventDispatcher\EventDispatcher->doDispatch() at phar:///usr/local/bin/composer/src/Composer/EventDispatcher/EventDispatcher.php:158
#8 8.573  Composer\EventDispatcher\EventDispatcher->dispatchPackageEvent() at phar:///usr/local/bin/composer/src/Composer/Installer/InstallationManager.php:399
#8 8.573  Composer\Installer\InstallationManager::Composer\Installer\{closure}() at phar:///usr/local/bin/composer/src/Composer/Installer/InstallationManager.php:414
#8 8.573  Composer\Installer\InstallationManager->executeBatch() at phar:///usr/local/bin/composer/src/Composer/Installer/InstallationManager.php:322
#8 8.573  Composer\Installer\InstallationManager->downloadAndExecuteBatch() at phar:///usr/local/bin/composer/src/Composer/Installer/InstallationManager.php:221
#8 8.573  Composer\Installer\InstallationManager->execute() at phar:///usr/local/bin/composer/src/Composer/Installer.php:839
#8 8.573  Composer\Installer->doInstall() at phar:///usr/local/bin/composer/src/Composer/Installer.php:300
#8 8.573  Composer\Installer->run() at phar:///usr/local/bin/composer/src/Composer/Command/InstallCommand.php:147
#8 8.573  Composer\Command\InstallCommand->execute() at phar:///usr/local/bin/composer/vendor/symfony/console/Command/Command.php:298
#8 8.574  Symfony\Component\Console\Command\Command->run() at phar:///usr/local/bin/composer/vendor/symfony/console/Application.php:1040
#8 8.574  Symfony\Component\Console\Application->doRunCommand() at phar:///usr/local/bin/composer/vendor/symfony/console/Application.php:301
#8 8.574  Symfony\Component\Console\Application->doRun() at phar:///usr/local/bin/composer/src/Composer/Console/Application.php:397
#8 8.574  Composer\Console\Application->doRun() at phar:///usr/local/bin/composer/vendor/symfony/console/Application.php:171
#8 8.574  Symfony\Component\Console\Application->run() at phar:///usr/local/bin/composer/src/Composer/Console/Application.php:137
#8 8.574  Composer\Console\Application->run() at phar:///usr/local/bin/composer/bin/composer:98
#8 8.574  require() at /usr/local/bin/composer:29

In the end, what that error really meant was that I was trying to apply a non-existent patch. We try to always use local patches rather than remote https ones, because it can avoid weird problems like the patch disappearing or changing (if the branch is updated). So our patches section in composer.json look like this:


    "extra": {
        "composer-exit-on-patch-failure": false,
        "patchLevel": {
            "drupal/core": "-p2"
        },
        "patches": {
            "drupal/address": {
                "Issue #3350959: Add token for 'Street address lines 1 and 2 combined'": "patches/upstream/address-3350959-street-address-combined-token-9.patch"
            "drupal/core": {
                "Issue #3065418: Empty sections render in Layout Builder - these need to be removed.": "patches/upstream/core-empty-sections-3065418-28.patch",
                "Issue #3342118: When an autocomplete entity reference is required via #states, no required marker is added": "patches/upstream/3342118-required-entity-references-states-8.patch",
            },
    ...

Note that our patches are local, i.e. patches/upstream/address-3350959-street-address-combined-token-9.patch.

I fixed this problem by adding the following line to cli.dockerfile:

COPY patches /app/patches

I think it might save other people some trouble if we created the patches directory with a README.md in this example repo, and included copying the patches directory in the default cli.dockerfile.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions