Description
While testing another issue locally, I encountered an issue which happens when you clear the composer cache before running on of the patch commands (e.g. patch:redo). The processReinstallOperation
, and more specifically the download
part, seems to resolve the promise too early without waiting for download completion, resulting in an empty package directory while patching.
The issue is clearly reproducible by adding some debug information to the promise chain in processReinstallOperation
, which shows that the patch operation happens before the installation of the package.
I managed to resolve the issue by using the Composer\Utils\SyncHelper::downloadAndInstallPackageSync
but this incurs passing the Composer
object around. I'm not well versed in composer plugins but will make a PR regardless.
To Reproduce
Steps to reproduce the behavior:
- Run
composer clear-cache
- Run
composer patch:redo --vvv
Optionally change the processReinstallOperation
to add debug information
return $installationManager
->uninstall($repository, $uninstallOperation)
->then(function () use ($installationManager, $installOperation, $repository) {
echo "Package uninstalled \n";
$package = $installOperation->getPackage();
return $installationManager->getInstaller($package->getType())->download($package);
})
->then(function () use ($installationManager, $installOperation, $repository) {
echo "Package downloaded \n";
$installationManager->install($repository, $installOperation);
})->then(function () {
echo "Package installed \n";
});
Expected
Packages are downloaded and installed before attempting to patch.
Actual
Packages are downloaded but patching begins before the installation process completed.