GCloud 应用部署失败,运行时为 7.4,"requires composer-runtime-api ^2.0.0"



我一直在尝试用gcloud app deploy构建PHP 7.4应用程序,但它失败了:

您的需求无法解析为一组可安装的软件包。问题1

  • jean85/pretty-package-versions 2.0.4 ->
  • jean85/pretty-package-versions 2.0.4要求composer-runtime-api ^2.0.0 ->

这是我的composer.json:

{
"require": {
"slim/slim": "^4.0",
"slim/psr7": "^1.3",
"slim/http": "^1.2",
"mongodb/mongodb": "1.5",
"ext-mongodb": "^1.6",
"jean85/pretty-package-versions": "^2.0",
"nesbot/carbon": "^2.52",
"php-di/php-di": "^6.3",
"vlucas/phpdotenv": "^5.3"
},
"require-dev": {
"phpunit/phpunit": "^9.5"   
}
}

:

我在网上找到的所有信息都是关于使用Composer 1而不是Composer 2的可能性。

我能在Google App Engine上找到的关于composer的最好信息是,当我在交互控制台中输入composer—version时,我得到的是"2.1.6"。就像我的本地开发环境一样。

最后,作为证据,这是云构建日志的尾部:

Step #2 - "build": Status: Downloaded newer image for eu.gcr.io/gae-runtimes/buildpacks/php74/builder:php74_20210728_7_4_21_RC00
Step #2 - "build": eu.gcr.io/gae-runtimes/buildpacks/php74/builder:php74_20210728_7_4_21_RC00
Step #2 - "build": Warning: Not restoring or caching layer data, no cache flag specified.
Step #2 - "build": ===> DETECTING
Step #2 - "build": 3 of 4 buildpacks participating
Step #2 - "build": google.php.composer  0.9.1
Step #2 - "build": google.php.appengine 0.9.0
Step #2 - "build": google.utils.label   0.0.1
Step #2 - "build": ===> ANALYZING
Step #2 - "build": Previous image with name "eu.gcr.io/voltaic-plating-324009/app-engine-tmp/app/default/ttl-18h:e941687b-9375-4927-97bb-eecaaf779592" not found
Step #2 - "build": ===> RESTORING
Step #2 - "build": ===> BUILDING
Step #2 - "build": === PHP - Composer (google.php.composer@0.9.1) ===
Step #2 - "build": --------------------------------------------------------------------------------
Step #2 - "build": Running "php -r echo PHP_VERSION;"
Step #2 - "build": 7.4.21Done "php -r echo PHP_VERSION;" (378.442053ms)
Step #2 - "build": DEBUG: Current dependency hash: "03f83fc1c2a57c9fa5ba4fe96c867d393f905ed37a0aecd50da328fd8392dae3"
Step #2 - "build": DEBUG:   Cache dependency hash: ""
Step #2 - "build": DEBUG: No metadata found from a previous build, skipping cache.
Step #2 - "build": Installing application dependencies.
Step #2 - "build": DEBUG: ***** CACHE MISS: "prod dependencies"
Step #2 - "build": --------------------------------------------------------------------------------
Step #2 - "build": Running "composer install --no-dev --no-progress --no-suggest --no-interaction --optimize-autoloader"
Step #2 - "build": Loading composer repositories with package information
Step #2 - "build": Installing dependencies from lock file
Step #2 - "build": Your requirements could not be resolved to an installable set of packages.
Step #2 - "build": 
Step #2 - "build":   Problem 1
Step #2 - "build":     - Installation request for jean85/pretty-package-versions 2.0.4 -> satisfiable by jean85/pretty-package-versions[2.0.4].
Step #2 - "build":     - jean85/pretty-package-versions 2.0.4 requires composer-runtime-api ^2.0.0 -> no matching package found.
Step #2 - "build": 
Step #2 - "build": Potential causes:
Step #2 - "build":  - A typo in the package name
Step #2 - "build":  - The package is not available in a stable-enough version according to your minimum-stability setting
Step #2 - "build":    see <https://getcomposer.org/doc/04-schema.md#minimum-stability> for more details.
Step #2 - "build":  - It's a private package and you forgot to add a custom repository to find it
Step #2 - "build": 
Step #2 - "build": Read <https://getcomposer.org/doc/articles/troubleshooting.md> for further common problems.
Step #2 - "build": Done "composer install --no-dev --no-progress --no-suggest --no-in..." (445.718128ms)
Step #2 - "build": Failure: (ID: 467317e4) Loading composer repositories with package information
Step #2 - "build": Installing dependencies from lock file
Step #2 - "build": Your requirements could not be resolved to an installable set of packages.
Step #2 - "build": 
Step #2 - "build":   Problem 1
Step #2 - "build":     - Installation request for jean85/pretty-package-versions 2.0.4 -> satisfiable by jean85/pretty-package-versions[2.0.4].
Step #2 - "build":     - jean85/pretty-package-versions 2.0.4 requires composer-runtime-api ^2.0.0 -> no matching package found.
Step #2 - "build": 
Step #2 - "build": Potential causes:
Step #2 - "build":  - A typo in the package name
Step #2 - "build":  - The package is not available in a stable-enough version according to your minimum-stability setting
Step #2 - "build":    see <https://getcomposer.org/doc/04-schema.md#minimum-stability> for more details.
Step #2 - "build":  - It's a private package and you forgot to add a custom repository to find it
Step #2 - "build": 
Step #2 - "build": Read <https://getcomposer.org/doc/articles/troubleshooting.md> for further common problems.

我怎么能确保我有作曲家2在谷歌云运行时,所以我没有得到"需要作曲家-运行时-api ^2.0.0 ->没有找到匹配的包。"错误呢?

目前Google提供的运行时图像是在Composer 2发布之前构建的(提示:最新提供的PHP还不包括8.0),所以如果你需要更新的东西,你不能使用Google提供的运行时。

他们没有提供更新的运行时或更好的选项,这有点遗憾,但所有的希望都没有失去。

你总是可以构建你自己的自定义运行时。

我能想到的最快和最肮脏的方式有自己的自定义运行时基于谷歌的PHP 7.4,但与Composer 2将添加一个Dockerfile旁边的app.yaml与以下:

FROM gcr.io/google-appengine/php74:latest
RUN composer self-update --2

runtime,在app.yaml中应该写:custom.

现在不能测试,但这应该会让你进入正确的轨道。

从这个答案来看,您现在可以在app.yaml中指定Composer版本:

build_env_variables:
GOOGLE_COMPOSER_VERSION: 2.2.1

requires composer-runtime-api ^2.0.0可以很容易地解决:使用Composer v2运行composer install,而不是使用任何旧版本。通过调用composer diagnose可以读取该版本。调试问题的所有进一步步骤都可以在错误消息

中链接的页面上找到。

相关内容

  • 没有找到相关文章

最新更新