vaimo / composer-patches

Applies a patch from a local or remote file to any package that is part of a given composer project. Patches can be defined both on project and on package level. Optional support for patch versioning, sequencing, custom patch applier configuration and composer command for testing/troubleshooting patches.
MIT License
291 stars 41 forks source link

RuntimeException: Could not delete file after upgrade to 5.1.2 #111

Closed bogdan-soroka-monsoonconsulting closed 7 months ago

bogdan-soroka-monsoonconsulting commented 1 year ago

After updating to version 5.1.2, the following error occurs from time to time:

  [RuntimeException]                                                                                                                                 
  Could not delete ...

Pre-requisites PHP: 8.2 composer: 2.2

To Reproduce Please use the files below: composer.json

{
    "config": {
        "allow-plugins": {
            "vaimo/composer-patches": true,
            "php-http/discovery": true
        }
    },
    "require": {
        "smile/elasticsuite": "2.11.4.2",
        "vaimo/composer-patches": "5.1.2"
    },
    "replace": {
        "magento/framework": "*",
        "magento/module-store": "*",
        "magento/module-backend": "*",
        "magento/module-catalog": "*",
        "magento/module-catalog-search": "*",
        "magento/module-catalog-graph-ql": "*",
        "magento/module-inventory-sales-api": "*",
        "magento/module-inventory-sales": "*",
        "magento/magento-composer-installer": "*",
        "magento/module-inventory-indexer": "*"
    },
    "extra": {
        "patches-file": "patches.json"
    }
}

patches.json

{
  "smile/elasticsuite": {
    "Test patch": "patch.patch"
  }
}

patch.patch

--- a/src/module-elasticsuite-core/etc/adminhtml/di.xml
+++ b/src/module-elasticsuite-core/etc/adminhtml/di.xml
@@ -21,7 +21,6 @@
     <type name="Magento\Framework\Notification\MessageList">
         <arguments>
             <argument name="messages" xsi:type="array">
-                <item name="elasticsuite" xsi:type="string">Smile\ElasticsuiteCore\Model\System\Message\NotificationAboutVersions</item>
                 <item name="elasticsuite_cluster_replicas_misconfig_warning" xsi:type="string">Smile\ElasticsuiteCore\Model\System\Message\WarningAboutClusterReplicasMisconfig</item>
             </argument>
         </arguments>

Sometimes it doesn't reproduce the first time you execute composer install, so execute the following command until it does:

rm -rf vendor/smile && composer install

Expected The patch must be applied.

Actual From time to time, a RuntimeException appears e.g.

  [RuntimeException]                                                                                                                                 
  Could not delete /vendor/smile/elasticsuite/src/module-elasticsuite-core/view/adminhtml/web/images:  

Notes The previous version (5.1.1) works properly, so we're using it for now.

michaelarnauts commented 8 months ago

We've also noticed this issue since we would get inconsistent CI builds due to this.

It took a while to figure out that this bug was the reason for this.

We will be downgrading to 5.1.1 until this is fixed.

hnsr commented 7 months ago

Just wanted to confirm that I also started running into this with a project with PHP 8.1, composer 2.6.6, after I upgraded vaimo/composer-patches to 5.1.2. The problem disappeared after reverting to 5.1.2