skip to Main Content

I’ve been trying to build a PHP 7.4 app with gcloud app deploy, but it fails with:

Your requirements could not be resolved to an installable set of packages.
Problem 1

  • Installation request for jean85/pretty-package-versions 2.0.4 -> satisfiable by jean85/pretty-package-versions[2.0.4].
  • jean85/pretty-package-versions 2.0.4 requires composer-runtime-api ^2.0.0 -> no matching package found.

This is my 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"   
  }
}

Notes:

All the information I’ve found on the Net was about a possible use of Composer 1 instead of Composer 2.

The best I can have about composer on Google App Engine is that when I type composer –version in the interactive console, I get "2.1.6" just like on my local dev environment.

Finally, as evidence, this is the tail of the Cloud Build log:

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 ([email protected]) ===
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.

How can I make sure I have composer 2 within Google Cloud runtime, so I don’t get the "requires composer-runtime-api ^2.0.0 -> no matching package found." error?

2

Answers


  1. requires composer-runtime-api ^2.0.0 can be solved pretty easy: run composer install with Composer v2, not with any older version. Reading that version is possible through calling composer diagnose. All further steps to debug the problem can be found on the page that is linked in the error message

    Login or Signup to reply.
  2. Currently the runtime images that Google provides have been built before Composer 2 was released (huge hint: latest provided PHP does not include 8.0 yet), so you can’t use the Google provided runtimes if you need anything newer than that.

    It’s bit of a shame that they do no provide newer runtimes or better options, but all hope is not lost.

    You can always build your own custom runtimes.

    The quickest and dirtiest way I can think of having your own custom runtime based on Google’s PHP 7.4 but with Composer 2 would be adding a Dockerfile alongside your app.yaml with the following:

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

    runtime, in app.yaml, should say: custom.

    Can’t test it right now, but this should get in you the right track.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search