Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exception with Composer 1.10.21+ #78

Open
djacques4gorilla opened this issue Apr 30, 2021 · 4 comments
Open

Exception with Composer 1.10.21+ #78

djacques4gorilla opened this issue Apr 30, 2021 · 4 comments
Labels

Comments

@djacques4gorilla
Copy link

When upgrading to Composer ~1.10.21, patches fail to apply due to a new exception being thrown by Composer.
Executing command (CWD): which patch The given CWD for the process does not exist: #0 /var/www/html/vendor/vaimo/composer-patches/src/Shell.php(57): Composer\Util\ProcessExecutor->execute('which patch', Object(Closure), '') #1 /var/www/html/vendor/vaimo/composer-patches/src/Patch/File/Applier.php(226): Vaimo\ComposerPatches\Shell->execute('which patch', '') #2 /var/www/html/vendor/vaimo/composer-patches/src/Patch/File/Applier.php(188): Vaimo\ComposerPatches\Patch\File\Applier->resolveOperationOutput(Array, Array, Array) #3 /var/www/html/vendor/vaimo/composer-patches/src/Patch/File/Applier.php(151): Vaimo\ComposerPatches\Patch\File\Applier->processOperationItems(Array, Array, Array, Array) #4 /var/www/html/vendor/vaimo/composer-patches/src/Patch/File/Applier.php(91): Vaimo\ComposerPatches\Patch\File\Applier->executeOperations(Array, Array, Array) #5 /var/www/html/vendor/vaimo/composer-patches/src/Package/PatchApplier/ItemProcessor.php(69): Vaimo\ComposerPatches\Patch\File\Applier->applyFile('/var/www/html/v...', '', Array) #6 /var/www/html/vendor/vaimo/composer-patches/src/Package/PatchApplier.php(74): Vaimo\ComposerPatches\Package\PatchApplier\ItemProcessor->processFileInfo(Object(Composer\Package\CompletePackage), Array) #7 /var/www/html/vendor/vaimo/composer-patches/src/Repository/PatchesApplier.php(333): Vaimo\ComposerPatches\Package\PatchApplier->applyPatches(Object(Composer\Package\CompletePackage), Array) #8 /var/www/html/vendor/vaimo/composer-patches/src/Repository/PatchesApplier.php(290): Vaimo\ComposerPatches\Repository\PatchesApplier->processPatchesForPackage(Object(Composer\Repository\InstalledFilesystemRepository), Object(Composer\Package\CompletePackage), Array) #9 /var/www/html/vendor/vaimo/composer-patches/src/Repository/PatchesApplier.php(249): Vaimo\ComposerPatches\Repository\PatchesApplier->processQueues(Object(Composer\Package\CompletePackage), Object(Composer\Repository\InstalledFilesystemRepository), Array, Array) #10 /var/www/html/vendor/vaimo/composer-patches/src/Repository/PatchesApplier.php(225): Vaimo\ComposerPatches\Repository\PatchesApplier->updatePackage(Object(Composer\Package\CompletePackage), Object(Composer\Repository\InstalledFilesystemRepository), Array, Array) #11 /var/www/html/vendor/vaimo/composer-patches/src/Repository/Processor.php(45): Vaimo\ComposerPatches\Repository\PatchesApplier->apply(Object(Composer\Repository\InstalledFilesystemRepository), Array) #12 /var/www/html/vendor/vaimo/composer-patches/src/Bootstrap.php(123): Vaimo\ComposerPatches\Repository\Processor->process(Object(Composer\Repository\InstalledFilesystemRepository), Object(Vaimo\ComposerPatches\Patch\DefinitionList\Loader), Object(Vaimo\ComposerPatches\Repository\PatchesApplier)) #13 /var/www/html/vendor/vaimo/composer-patches/src/Bootstrap.php(93): Vaimo\ComposerPatches\Bootstrap->applyPatchesWithConfig(Object(Vaimo\ComposerPatches\Config), true) #14 /var/www/html/vendor/vaimo/composer-patches/src/Plugin.php(111): Vaimo\ComposerPatches\Bootstrap->applyPatches(true) #15 /var/www/html/vendor/vaimo/composer-patches/src/Utils/RuntimeUtils.php(20): Vaimo\ComposerPatches\Plugin->Vaimo\ComposerPatches\{closure}() #16 /var/www/html/vendor/vaimo/composer-patches/src/Plugin.php(118): Vaimo\ComposerPatches\Utils\RuntimeUtils->executeWithPostAction(Object(Closure), Object(Closure)) #17 [internal function]: Vaimo\ComposerPatches\Plugin->postInstall(Object(Composer\Script\Event)) #18 phar:///usr/bin/composer/src/Composer/EventDispatcher/EventDispatcher.php(164): call_user_func(Array, Object(Composer\Script\Event)) #19 phar:///usr/bin/composer/src/Composer/EventDispatcher/EventDispatcher.php(96): Composer\EventDispatcher\EventDispatcher->doDispatch(Object(Composer\Script\Event)) #20 phar:///usr/bin/composer/src/Composer/Autoload/AutoloadGenerator.php(112): Composer\EventDispatcher\EventDispatcher->dispatchScript('pre-autoload-du...', true, Array, Array) #21 phar:///usr/bin/composer/src/Composer/Installer.php(307): Composer\Autoload\AutoloadGenerator->dump(Object(Composer\Config), Object(Composer\Repository\InstalledFilesystemRepository), Object(Composer\Package\RootPackage), Object(Composer\Installer\InstallationManager), 'composer', false) #22 phar:///usr/bin/composer/src/Composer/Command/InstallCommand.php(122): Composer\Installer->run() #23 phar:///usr/bin/composer/vendor/symfony/console/Command/Command.php(245): Composer\Command\InstallCommand->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput)) #24 phar:///usr/bin/composer/vendor/symfony/console/Application.php(835): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput)) #25 phar:///usr/bin/composer/vendor/symfony/console/Application.php(185): Symfony\Component\Console\Application->doRunCommand(Object(Composer\Command\InstallCommand), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput)) #26 phar:///usr/bin/composer/src/Composer/Console/Application.php(281): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput)) #27 phar:///usr/bin/composer/vendor/symfony/console/Application.php(117): Composer\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput)) #28 phar:///usr/bin/composer/src/Composer/Console/Application.php(113): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput)) #29 phar:///usr/bin/composer/bin/composer(61): Composer\Console\Application->run() #30 /usr/bin/composer(24): require('phar:///usr/bin...') #31 {main} Failed to apply the patch. Halting execution!
Applying the patches works properly with the same patch list and same version of Vaimo Composer Patches when using Composer 1.10.20 or earlier. Since Composer 1.10.21 introduces support for the new format of GitHub tokens, upgrading environments to that version or later is important, but can't be completed until this error is resolved.

Pre-requisites

  1. Composer 1.10.21
  2. vaimo/composer-patches 4.22.4

To Reproduce
Steps to reproduce the behavior:

  1. Delete the vendor directory
  2. Run composer install

Expected
Patches apply successfully

Actual
The first patch fails with "The given CWD for the process does not exist" and the patch application process is halted.

Notes
See composer/composer@abcf9e9#diff-0d77dff282a3465a0ecf922a588d76fb9e09d64655c5c31fd6b702a63640574e for the related changes to Composer.
It looks like previous versions of Composer would simply silently fail and still run the CLI command even if CWD was null or invalid. Since the command is which patch, it would work from any directory, so it didn't matter what the current one was. I suppose one way to fix this would be to properly define the value of $cwd when unspecified in the call to execute() so that the exception isn't being thrown.

@djacques4gorilla
Copy link
Author

Adding
$cwd = $cwd ?: getcwd();
at vendor/vaimo/composer-patches/src/Shell.php:39 locally allowed patches to be installed successfully.

@allanpaiste allanpaiste added the bug label May 7, 2021
@allanpaiste
Copy link
Contributor

Note taken + many thanks for the fix provided! will be addressing this this weekend!

@djacques4gorilla
Copy link
Author

Hi @allanpaiste ,

Do you have any ETA for the new tag that will include this fix? Magento Cloud has updated their Composer version on their build server to an incompatible version, so we had to move some projects to a fork including the fix in order to continue to apply patches. If anyone else is using your extension on Magento Cloud in graceful mode, they might be deploying their projects without any patches applied unbeknownst to them, potentially exposing them to security issues or bugs that were previously fixed thanks to the patches. Since Magento Cloud doesn't keep snapshot build tags, even if they do find out the patches aren't applying afterward, they will be unable to rollback to a state where patches were applied.

@djacques4gorilla
Copy link
Author

@zamoroka Any movement on this issue? I see you have published your first new version since I reported the bug, but it's unclear whether the issue has been resolved or not.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants