composer-patches icon indicating copy to clipboard operation
composer-patches copied to clipboard

Resolve RuntimeException "Could not delete file"

Open bogdan-soroka-monsoonconsulting opened this issue 1 year ago • 3 comments

Fixes #111

This looks like it will revert at least part of https://github.com/vaimo/composer-patches/pull/107 which was created to fix #103. I can't see any explanation in #107 nor here to help me understand why this is the correct approach, and there's no reference to #103 here so I'm unsure if that's been taken into account. There don't seem to be any changes to the test-suite here to confirm that this change fixes the intended bug and does not break any other functionality. @bogdan-soroka-monsoonconsulting please can you provide some more information about this change?

fredden avatar Dec 05 '23 09:12 fredden

Hi @fredden, Long story short:

  • in version 5.1.1: downloading and installing the package occur simultaneously after uninstalling (unzip sometimes starts before a package has been downloaded #103)
  • in version 5.2.2: uninstalling and installing the package occur simultaneously (large modules sometimes cannot be uninstalled before the installation starts #111)
  • in this pull request: first uninstall the package, then download it, and only then install it

Thanks for the explanation. The original code looks like it does "uninstall, then download, then install." I guess the promise library used treats two consecutive ->then() calls as "run in parallel," not "run in sequence."

fredden avatar Dec 05 '23 19:12 fredden

Any update on this fix?

michaelarnauts avatar Mar 29 '24 12:03 michaelarnauts

@zamoroka-vaimo or @zamoroka, please can you merge this in and tag a new release? This module cannot patch itself, so we can't apply this like bug-fixes for other packages.

fredden avatar Apr 18 '24 09:04 fredden

This module cannot patch itself

Technically it can patch itself, but the bug in question is most likely to happen the first time that we run composer install for a project (like in our CI pipeline where we start with a fresh checkout from version control). By the time the new code is written to the filesystem, PHP has already read the old files and has the old code running in memory. Subsequent times that Composer runs, the new/patched code is used.

fredden avatar Apr 18 '24 10:04 fredden

added to 5.2.0 https://github.com/vaimo/composer-patches/releases/tag/5.2.0 Thanks for your contribution 🙌

zamoroka-vaimo avatar Apr 18 '24 10:04 zamoroka-vaimo