Skip to content

Weird Behaviour where package is deleted before patch is applied #113

@natedawg92

Description

@natedawg92

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

  1. Install mirasvit/module-search-ultimate via composer
  2. 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:

  1. run composer install or composer 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.

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