-
Notifications
You must be signed in to change notification settings - Fork 43
Description
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
- Composer 1.10.21
- vaimo/composer-patches 4.22.4
To Reproduce
Steps to reproduce the behavior:
- Delete the vendor directory
- 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.