Installing task binary: "text file busy"
The condition below avoids "text file busy" error partially.
If the hash_file result is different (if the task binaries are different), we could be running task and still try to replace the task binary.
On Tugboat, a preview already had the task binary and I got the "text file busy" error.
To fix it, I ran, before running task commands, composer install and that installed the correct task version.
It is a very particular issue, and I would like to know if it is a drainpipe code or a drainpipe documentation issue... or not Drainpipe's issue at all.
It failed when running ./vendor/bin/task drupal:composer:development
https://github.com/Lullabot/drainpipe/blob/main/src/BinaryInstaller.php#L249
// Check the vendor/bin directory first, otherwise we could hit a
// condition where task has called "composer install --no-dev" after
// "composer install" and tries to replace the task binary - this will
// fail because the binary is already being run and you'll get a "failed
// to open stream: Text file busy" error.
if (file_exists($binDestination) && hash_file('sha256', $binDestination) === hash_file('sha256', $cacheExtractedBinary)) {
$this->io->write(sprintf('%s v%s (%s) already exists in bin-dir, not overwriting.', $binary, $version, $sha));
}
@beto-aveiga I think this is already fixed in https://github.com/Lullabot/drainpipe/pull/679 which is just waiting a new drainpipe release. Could you try upgrading to main and see if you can reproduce this still?
@deviantintegral
It still has issues using main for both Drainpipe packages.
We need to check that the file is not busy in case the binary is Task (or any other binary that we are trying to replace). Alternatively, we need to run composer install before setting the right binary.
Did you see the test for this at https://github.com/Lullabot/drainpipe/pull/679/files#diff-35458453f942bb563be9546b6d08af7e8a167fb25d3c1e8bcbef348c981c0063R80-R93? Unfortunately the first time this runs you need to run it twice because composer still has the old code in memory. That will go away as sites get upgraded to the fixed code.
If your case, using the previous release, task drupal:composer:development should consistently fail. Once upgraded to main task drupal:composer:development || task drupal:composer:development should run twice but pass the second time.
I think this isn't an issue anymore as this hasn't come up again in a year.