执行命令:composer install 时,报错:Script Google\Task\Composer::cleanup handling the pre-autoload-dump event terminated with an exception

1、执行命令:composer install 时,报错:Script Google\Task\Composer::cleanup handling the pre-autoload-dump event terminated with an exception。如图1

图1

/object # composer install
Installing dependencies from lock file (including require-dev)
Verifying lock file contents can be installed on current platform.
Warning: The lock file is not up to date with the latest changes in composer.json. You may be getting outdated dependencies. It is recommended that you run `composer update` or `composer update <package name>`.
Package operations: 1 install, 0 updates, 0 removals
  - Installing google/apiclient-services (v0.226.0): Extracting archive



Package fzaninotto/faker is abandoned, you should avoid using it. No replacement was suggested.
Package swiftmailer/swiftmailer is abandoned, you should avoid using it. Use symfony/mailer instead.
Package moontoast/math is abandoned, you should avoid using it. Use brick/math instead.
Package phpunit/php-token-stream is abandoned, you should avoid using it. No replacement was suggested.
Generating optimized autoload files
> Google\Task\Composer::cleanup
Removing 209 google services
Script Google\Task\Composer::cleanup handling the pre-autoload-dump event terminated with an exception


  [Symfony\Component\Filesystem\Exception\IOException]
  Failed to remove directory "/object/vendor/google/apiclient-services/src/Assuredworkloads": rmdir(/object/vendor/google/apiclient-services/src/Assuredworkloads): Directory not empty.


install [--prefer-source] [--prefer-dist] [--dry-run] [--dev] [--no-suggest] [--no-dev] [--no-autoloader] [--no-scripts] [--no-progress] [--no-install] [-v|vv|vvv|--verbose] [-o|--optimize-autoloader] [-a|--classmap-authoritative] [--apcu-autoloader] [--apcu-autoloader-prefix APCU-AUTOLOADER-PREFIX] [--ignore-platform-req IGNORE-PLATFORM-REQ] [--ignore-platform-reqs] [--] [<packages>]...

2、查看 /vendor/google/apiclient/README.md,清理未使用的服务,有超过 200 个 Google API 服务。 很有可能你不会都想要。 为了避免在您的代码中传送这些依赖项,你可以运行 `Google\Task\Composer::cleanup` 任务并指定服务你想保留在 `composer.json` 中:

{
    "require": {
        "google/apiclient": "^2.12.1"
    },
    "scripts": {
        "pre-autoload-dump": "Google\\Task\\Composer::cleanup"
    },
    "extra": {
        "google/apiclient-services": [
            "Drive",
            "YouTube"
        ]
    }
}

3、编辑 composer.json,决定在 scripts 中,先删除掉:”pre-autoload-dump”: “Google\\Task\\Composer::cleanup” 。如图2

图2

    "scripts": {
        "post-autoload-dump": [
            "Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
            "@php artisan package:discover --ansi"
        ],
        "post-root-package-install": [
            "@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
        ],
        "post-create-project-cmd": [
            "@php artisan key:generate --ansi"
        ],
        "lint": "phpcs --standard=PSR1,PSR2,./ruleset.xml --ignore=config/us-zipcode.php app/ routes/ config/ ",
        "lint-fix": "phpcbf --standard=PSR1,PSR2 --ignore=config/us-zipcode.php  app/ routes/ config/ "
    }

4、执行 composer update 时,不再报错。但是,这是在容器中执行,后来在本地 Windows 主机上执行不存在此问题。如图3

图3

永夜