【发布时间】:2021-11-07 03:47:51
【问题描述】:
我一直在尝试使用gcloud app deploy 构建一个 PHP 7.4 应用程序,但它失败了:
您的要求无法解决为一组可安装的软件包。 问题一
- jean85/pretty-package-versions 2.0.4 的安装请求 -> 可由 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”,就像在我的本地开发环境中一样。
最后,作为证据,这是 Cloud Build 日志的尾部:
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.
如何确保我在 Google Cloud 运行时中有 composer 2,所以我没有收到“需要 composer-runtime-api ^2.0.0 -> 找不到匹配的包”。错误?
【问题讨论】:
-
这是 Composer 方面的一个错误。看看这个GitHub issue link 并尝试通过运行
composer self-update 2.1.3将 Composer 升级到 2.1.3 的最新版本 -
@PriyashreeBhadra 最新作曲家是 2.1.6,而不是 2.1.3。并且 OP 说他们有“2.1.16”(它不存在,很可能是“2.1.6”的错字)。您提到的错误已在 6 月份解决,因此这里不应该是这种情况。您的建议会使作曲家降级到比最新版本更旧的版本。
-
@yivi 你是对的,但我想确认作曲家的版本,因为他发布了“2.1.16”,但我们假设它的 2.1.6 不存在,因为 2.1.16 不存在。
-
只是让大家知道我通过使用
mongodb/mongodb 1.5、ext-mongodb 1.6并使用extension=mongodb.so添加单行php.ini文件,成功构建了应用程序并无错误地连接到外部MongoDB 集群在我的应用发行版的根目录下。
标签: php composer-php gcloud