Weird Behaviour where package is deleted before patch is applied
natedawg92 opened this issue · comments
When attempting to patch a package that includes multiple Magento 2 modules (Yes bad package structure) the package will be installed then the subdirectory (containing all the sub modules) will be deleted, the patch then is attempted but obviously fails as there is no file to be patched as it was deleted.
This is happening for me on mirasvit/module-search-ultimate
Pre-requisites
- Install
mirasvit/module-search-ultimate
via composer - Create a patch for one of the sub module
diff --git a/src/SearchAutocomplete/Controller/Ajax/Suggest.php b/src/SearchAutocomplete/Controller/Ajax/Suggest.php
index 8247648..fe78b6c 100644
--- a/src/SearchAutocomplete/Controller/Ajax/Suggest.php
+++ b/src/SearchAutocomplete/Controller/Ajax/Suggest.php
@@ -59,7 +59,7 @@ class Suggest extends Action
$response->setHeader('cache-control', 'max-age=86400, public, s-maxage=86400', true);
$data = $this->serializer->serialize($this->result->toArray());
- $data .= $this->layout->createBlock(Debug::class)->toHtml();
+
$response->representJson($data);
}
}
To Reproduce
Steps to reproduce the behaviour:
- run
composer install
orcomposer patch:apply
Expected
- Patch is applied
Actual
- Files attempting to be patched are deleted
Notes
result from composer instal -vvv
...
Package operations: 1 install, 0 updates, 0 removals
Installs: mirasvit/module-search-ultimate:2.2.33
Reading /home/www-data/.composer/cache/files/mirasvit/module-search-ultimate/d3e7c59d04df04f537d895bcc6db73164df3cb1c.tar from cache
- Loading mirasvit/module-search-ultimate (2.2.33) from cache
...
[404] https://repo.packagist.org/p2/mirasvit/module-search-ultimate.json
- Installing mirasvit/module-search-ultimate (2.2.33): Extracting archive
Package laminas/laminas-zendframework-bridge is abandoned, you should avoid using it. No replacement was suggested.
Package sebastian/phpcpd is abandoned, you should avoid using it. No replacement was suggested.
Generating autoload files
> pre-autoload-dump: Vaimo\ComposerPatches\Plugin->postInstall
Processing patches configuration
- Removing mirasvit/module-search-ultimate (2.2.33)
Executing async command (CWD): rm -rf '/var/www/html/vendor/mirasvit/module-search-ultimate'
Reading /home/www-data/.composer/cache/files/mirasvit/module-search-ultimate/d3e7c59d04df04f537d895bcc6db73164df3cb1c.tar from cache
- Loading mirasvit/module-search-ultimate (2.2.33) from cache
- Installing mirasvit/module-search-ultimate (2.2.33): Extracting archive
Executing command (CWD): rm -rf '/var/www/html/vendor/mirasvit/module-search-ultimate/src'
- Applying patches for mirasvit/module-search-ultimate (1)
~ windandkite/driftworks-m2: patches/composer/mirasvit/module-search-ultimate/fix-autosearch-breaking-quote.patch [NEW]
resolve creating new quote when client use search
Executing command (/var/www/html/vendor/mirasvit/module-search-ultimate): which patch
The given CWD for the process does not exist: /var/www/html/vendor/mirasvit/module-search-ultimate
...
Failed to apply the patch. Halting execution!
As can be seen the package to be patched is remove with rm -rf '/var/www/html/vendor/mirasvit/module-search-ultimate'
, then installed then the src
directory is deleted with rm -rf '/var/www/html/vendor/mirasvit/module-search-ultimate/src'
before the patch is applied.
I have attempted to install the patch using multiple different cwd options and updating the patch file paths to no avail as well.
Encountering the same problem here as well with a different magento 2 module.
Processing patches configuration
Reading /data/.composer/cache/files/a486481dfeb2830a05510422506d093f/003c7340315e1c5e820d83750fcd7fae9acfc77a.file from cache
- Removing bsscommerce/product-stock-alert (1.3.6)
Executing async command (CWD): rm -rf '/data/.../magento2/vendor/bsscommerce/product-stock-alert'
Reading /data/.composer/cache/files/bsscommerce/product-stock-alert/2e2ff0570ef48a9309c2222a6416a374bfa00c5c.tar from cache
- Loading bsscommerce/product-stock-alert (1.3.6) from cache
- Installing bsscommerce/product-stock-alert (1.3.6): Extracting archive
Executing command (CWD): rm -rf '/data/.../magento2/vendor/bsscommerce/product-stock-alert/view'
Executing command (CWD): rm -rf '/data/.../magento2/vendor/bsscommerce/product-stock-alert/Block'
- Applying patches for bsscommerce/product-stock-alert (1)
~ .../magento2: patches/bsscommerce/product-stock-alert/0001-Fixed-check-for-MSI.patch [NEW]
From 4c63a329c22800126dee5aefffe98fdfa3d32870 Mon Sep 17 00:00:00 2001
From: ...
Date: Thu, 2 Feb 2023 14:37:30 +0100
Subject: [PATCH] Fixed check for MSI
Executing command (/data/.../magento2/vendor/bsscommerce/product-stock-alert): which patch
The provided cwd "/data/.../magento2/vendor/bsscommerce/product-stock-alert" does not exist.
I think this is the same issue as #111
The workaround is to downgrade to version 5.1.1
composer require vaimo/composer-patches:5.1.1
We notice the same issue with various Mirasvit modules. Had to downgrade as @bogdan-soroka-monsoonconsulting mentioned to be able to continue.