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

Installing task binary: "text file busy" #694

Open
beto-aveiga opened this issue Sep 17, 2024 · 3 comments
Open

Installing task binary: "text file busy" #694

beto-aveiga opened this issue Sep 17, 2024 · 3 comments

Comments

@beto-aveiga
Copy link
Collaborator

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));
        }
@deviantintegral
Copy link
Member

@beto-aveiga I think this is already fixed in #679 which is just waiting a new drainpipe release. Could you try upgrading to main and see if you can reproduce this still?

@beto-aveiga
Copy link
Collaborator Author

@deviantintegral
It still has issues using main for both Drainpipe packages.
image

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.

@deviantintegral
Copy link
Member

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.

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

No branches or pull requests

2 participants