googleapis / google-api-php-client

A PHP client library for accessing Google APIs
http://googleapis.github.io/google-api-php-client/
Apache License 2.0
9.32k stars 3.52k forks source link

Text file busy when removing unused services using the cleanup class #2527

Closed mathewberry closed 4 months ago

mathewberry commented 10 months ago

Environment details

Steps to reproduce

  1. Install client composer require google/apiclient:^2.15.0
  2. Add the cleanup scripts
        "scripts": {
            "pre-autoload-dump": "Google\\Task\\Composer::cleanup"
        },
        "extra": {
            "google/apiclient-services": [
                 "ShoppingContent",
            ]
        }
  3. Run composer update

Code example

composer update

Exception Example

Script Google\Task\Composer::cleanup handling the pre-autoload-dump event terminated with an exception

In Filesystem.php line 200:

Failed to remove directory "(/path/to/project/vendor/google/apiclient-services/src/._Mj2": rmdir(/path/to/project/vendor/google/apiclient-services/src/._Mj2): Text file busy
bshaffer commented 9 months ago

See #2504 and https://github.com/googleapis/google-api-php-client/pull/2532

mathewberry commented 9 months ago

I have tried this fix previously ,and again just now, in case @bshaffer but the issue still occurs. It doesn't appear to be an issue with composer timing as the dump takes a minute or 2, it just seems to be tripping up when deleting the unused services.

The script seems to rename the google/api-client-services/[DIR] folder first then start unlinking files with no issue, but gets stuck removing the Resource folder in the API service and that appears to be what's throwing the Text file busy error.

bshaffer commented 9 months ago

@mathewberry thanks for the feedback, then honestly I'm not sure what could be causing the problem. It could be something wrong with the order things are being removed by the symfony Filesystem component?

bshaffer commented 4 months ago

One thing I noticed here is you're receiving the error for a ._Mj2 file. I'm not sure where those are coming from, but they're not distributed as part of our package. This could be the problem.

Because we haven't received an update on this, I'm closing it for now. Please reopen it or submit a new issue if you continue to have this problem.

mathewberry commented 4 months ago

@bshaffer I think this can stay closed, but for any update for anyone that comes across this. If you're using Windows with Virtualbox and Vagrant, the way Vagrant maps folders between the virtual environment and the physical Windows host, there can be significant lag which causes the "Text File Busy" error.

It seems to have stopped in google/apiclient v2.15.3 for myself, it could also be due to numerous factors however so I can't guarantee this will work for anyone else experiencing it.