部署更新的 Laravel 应用程序 - 错误:无法安装系统包 - 已解决

时间:2021-06-06 11:11:11

标签: laravel heroku deployment composer-php

更新:看来我发现了一个错误。 Here the ticket 在我创建的 github 上。 大卫会在白天解决问题。


我只是尝试按照 Heroku guide 创建一个简单的 Laravel 应用程序(即使没有数据库连接)并部署在 Heroku 应用程序上。但是,似乎在使用 Composer 2 时存在问题(请参阅此处的日志)。回滚到 Composer 1 没问题。 在 Heroku documentation 中表示支持 Composer 2,但显然我做错了什么,因为它给了我一个错误。

当我将修改推送到 Heroku 时,我收到此错误:

 !     The following is the full output from the installation attempt:
 !     
 !     > Loading repositories with available runtimes and extensions
 !     > Updating dependencies
 !     > Your requirements could not be resolved to an installable set of packages.
 !     > 
 !     >   Problem 1
 !     >     - The requested package composer-plugin-api could not be found in any version, there may be a typo in the package name.
 !     > 
 !     
 !     For reference, the following runtimes are currently available:
 !     
 !     PHP:  8.0.6, 8.0.3, 8.0.2, 8.0.1, 8.0.0, 7.4.19, 7.4.16, 
 !     7.4.15, 7.4.14, 7.4.13, 7.4.12, 7.4.11, 7.4.10, 7.4.9, 
 !     7.4.8, 7.4.7, 7.4.6, 7.4.5, 7.4.4, 7.4.3, 7.4.2, 7.3.28, 
 !     7.3.27, 7.3.26, 7.3.25, 7.3.24, 7.3.23, 7.3.22, 7.3.21, 
 !     7.3.20, 7.3.19, 7.3.18, 7.3.17, 7.3.16, 7.3.15, 7.3.14, 
 !     7.3.13, 7.2.34, 7.2.33, 7.2.32, 7.2.31, 7.2.30, 7.2.29, 
 !     7.2.28, 7.2.27, 7.2.26, 7.1.33
 !     
 !     Please verify that all requirements for runtime versions in
 !     'composer.lock' are compatible with the list above, and ensure
 !     all required extensions are available for the desired runtimes.
 !     
 !     
 !     For a list of supported runtimes & extensions on Heroku, please
 !     refer to: https://devcenter.heroku.com/articles/php-support
 !     Push rejected, failed to compile PHP app.
 !     Push failed

我试过

composer require composer-plugin-api

但是还是报错。我使用 PHP 7.4.19,我的应用程序使用 Laravel 7 完成。

这是我的composer.json

的内容
{
    "name": "laravel/laravel",
    "type": "project",
    "description": "The Laravel Framework.",
    "keywords": [
        "framework",
        "laravel"
    ],
    "license": "MIT",
    "require": {
        "php": "^7.2",
        "composer-plugin-api": "^2.1",
        "barryvdh/laravel-ide-helper": "^2.6",
        "doctrine/dbal": "^2.10",
        "fideloper/proxy": "^4.2",
        "guzzlehttp/guzzle": "^6.5",
        "jeroenzwart/laravel-csv-seeder": "^1.2",
        "kris/laravel-form-builder": "^1.22",
        "laravel-frontend-presets/bulma": "^3.0",
        "laravel/framework": "^6.12",
        "laravel/scout": "^7.2",
        "laravel/tinker": "^2.1",
        "league/csv": "^9.5",
        "michelf/php-markdown": "^1.9",
        "nesbot/carbon": "^2.29",
        "proengsoft/laravel-jsvalidation": "^2.5",
        "psr/log": "^1.1",
        "spatie/laravel-collection-macros": "^6.0",
        "spatie/laravel-permission": "^3.6",
        "spatie/laravel-searchable": "^1.5",
        "yajra/laravel-datatables": "^1.5"
    },
    "require-dev": {
        "facade/ignition": "^1.4",
        "mockery/mockery": "^1.0",
        "nunomaduro/collision": "^3.0",
        "phpunit/phpunit": "^8.0"
    },
    "config": {
        "optimize-autoloader": true,
        "preferred-install": "dist",
        "sort-packages": true
    },
    "extra": {
        "laravel": {
            "dont-discover": []
        }
    },
    "autoload": {
        "psr-4": {
            "App\\": "app/"
        },
        "classmap": [
            "database/seeds",
            "database/factories"
        ]
    },
    "autoload-dev": {
        "psr-4": {
            "Tests\\": "tests/"
        }
    },
    "minimum-stability": "dev",
    "prefer-stable": true,
    "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"
        ]
    }
}

谢谢

3 个答案:

答案 0 :(得分:0)

只是更新: 我还使用 Heroku devcenter 提供的 this guide 创建了一个简单的 Laravel 应用程序并将其部署在 heroku 上,我得到了相同的结果。

我想这可能是 Composer 2 的问题,但阅读 Heroku 文档我理解 Heroku 支持 Composer 2

答案 1 :(得分:0)

目前我发现解决的唯一方法似乎是将 Composer 带回版本 1。这样做时,heroku 接受了部署。

答案 2 :(得分:0)

错误已关闭。现在它起作用了。 Github ticket