没有不值得去解决的问题,也没有不值得去学习的技术!

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

执行命令: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

执行命令:composer install 时,报错:Script Google\Task\Composer::cleanup handling the pre-autoload-dump event terminated with an exception。
图1
Plaintext
/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 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] [--] []...


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

Plaintext
{
    "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

编辑 composer.json,决定在 scripts 中,先删除掉:"pre-autoload-dump": "Google\\Task\\Composer::cleanup" 。
图2
Plaintext
    "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

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

关于作者 · 持续学习与技术实践

我是一名拥有 15 年以上开发经验的技术从业者,自 2013 年起持续运营个人技术博客,记录工作与个人项目中遇到的真实问题,以及解决问题过程中的探索、实践和思考。

除了技术写作,我也在持续开发和维护自己的独立项目,探索新技术和新工具在实际场景中的应用。我始终相信,没有不值得去解决的问题,也没有不值得去学习的技术。

如果这篇文章对你有所帮助,欢迎浏览博客中的其他文章,也欢迎交流技术经验与想法。

关于我  ·  GitHub  ·  邮件联系