heroku / heroku-buildpack-php

Heroku's buildpack for PHP applications.

Home Page:https://devcenter.heroku.com/categories/php

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Installing platform packages fails when package provides an extension

onlineth opened this issue · comments

One of the packages we require utilizes the composer packaging linking provide feature where it provides a PHP extension. This appears to cause an issue with the buildpack when it's building our project.

An example of a package that is causing an issue in the buildpack is symfony/polyfill-mbstring. In the composer.lock, the polyfill-mbstring packages has the following included,

            "provide": {
                "ext-mbstring": "*"
            },

This is a change from symfony/polyfill#374. When attempting to build a project with this, the following error is shown,

# pack build testapp --buildpack heroku/php
20: Pulling from heroku/buildpacks
Digest: sha256:e553137056aed3a2fce023e9f5dcac6f133070c62549fd390d39cb16e532822e
Status: Image is up to date for heroku/buildpacks:20
20: Pulling from heroku/pack
Digest: sha256:f5561ee7b732710446b2a77bf69f77a4fd43b77efc0aebb135d042954b31dda6
Status: Image is up to date for heroku/pack:20
===> DETECTING
heroku/php 0.3.1
===> ANALYZING
Restoring metadata for "heroku/php:shim" from cache
===> RESTORING
Restoring data for "heroku/php:shim" from cache
===> BUILDING
-----> Bootstrapping...
-----> Installing platform packages...
       NOTICE: No runtime required in composer.json; requirements
       from dependencies in composer.lock will be used for selection

 !     ERROR: Failed to install system packages!
 !
 !     Your platform requirements (for runtimes and extensions) could
 !     not be resolved to an installable set of dependencies, or a
 !     platform package repository was unreachable.
 !
 !     This usually means that you (or packages you are using) depend
 !     on a combination of PHP versions and/or extensions that are
 !     currently not available on Heroku.
 !
 !     The following is the full output from the installation attempt:
 !
 !     > You are using Composer 1 which is deprecated. You should upgrade to Composer 2, see https://blog.packagist.com/deprecating-composer-1-support/
 !     > Loading repositories with available runtimes and extensions
 !     > Updating dependencies
 !     > Your requirements could not be resolved to an installable set of packages.
 !     >
 !     >   Problem 1
 !     >     - symfony/polyfill-mbstring v1.24.0 requires php >=7.1 -> satisfiable by php[7.3.24, 7.3.25, 7.3.26, 7.3.27, 7.3.28, 7.3.29, 7.3.30, 7.3.31, 7.3.32, 7.3.33, 7.4.12, 7.4.13, 7.4.14, 7.4.15, 7.4.16, 7.4.19, 7.4.20, 7.4.21, 7.4.22, 7.4.23, 7.4.24, 7.4.25, 7.4.26, 7.4.27, 8.0.0, 8.0.1, 8.0.10, 8.0.11, 8.0.12, 8.0.13, 8.0.14, 8.0.2, 8.0.3, 8.0.6, 8.0.7, 8.0.8, 8.0.9, 8.1.0, 8.1.1].
 !     >     - don't install symfony/polyfill-mbstring v1.24.0|don't install php 7.3.24
 !     >     - don't install symfony/polyfill-mbstring v1.24.0|don't install php 7.3.25
...
 !     >     - don't install symfony/polyfill-mbstring v1.24.0|don't install php 8.1.0
 !     >     - don't install symfony/polyfill-mbstring v1.24.0|don't install php 8.1.1
 !     >     - Installation request for symfony/polyfill-mbstring v1.24.0 -> satisfiable by symfony/polyfill-mbstring[v1.24.0].
 !     >
 !     > Running update with --no-dev does not mean require-dev is ignored, it just means the packages will not be installed. If dev requirements are blocking the update you have to resolve those problems.
 !
 !     For reference, the following runtimes are currently available:
 !
 !     PHP:  8.1.1, 8.1.0, 8.0.14, 8.0.13, 8.0.12, 8.0.11, 8.0.10,
 !     8.0.9, 8.0.8, 8.0.7, 8.0.6, 8.0.3, 8.0.2, 8.0.1, 8.0.0,
 !     8.0.0RC4, 7.4.27, 7.4.26, 7.4.25, 7.4.24, 7.4.23, 7.4.22,
 !     7.4.21, 7.4.20, 7.4.19, 7.4.16, 7.4.15, 7.4.14, 7.4.13,
 !     7.4.12, 7.3.33, 7.3.32, 7.3.31, 7.3.30, 7.3.29, 7.3.28,
 !     7.3.27, 7.3.26, 7.3.25, 7.3.24
 !
 !     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.
 !
 !     When choosing a PHP runtimes and extensions, please also ensure
 !     they are available on your app's stack (heroku-20), and select
 !     a different stack if needed after consulting the article below.
 !
 !     For a list of supported runtimes & extensions on Heroku, please
 !     refer to: https://devcenter.heroku.com/articles/php-support

ERROR: failed to build: exit status 1
ERROR: failed to build: executing lifecycle: failed with status code: 51

To replicate the issue, in a new directory

composer require symfony/polyfill-mbstring
pack build testapp --buildpack heroku/php

Hi!

This used to be a known edge case (phpseclib/bcmath_compat#1), but now with symfony declaring all these provides, it's gotten a lot bigger ;)

It's related to how these provided packages are bundled into our PHP packages, where they are declared as replaced. In Composer 1, this leads to a conflict, which is one of the reasons why we're moving this platform dependency installation process to Composer 2 (this is unrelated to what version of Composer you used for your composer.lock).

I'm hoping we can land the fix next week.

In the meantime, please pin your dependencies to v1.23.0 of those polyfills.

Just decided to land a quick hotfix in the meantime; expect that tomorrow (Friday).

Fix published, so y'all should be able to deploy normally. Apologies for the interruption. Enjoy your weekends!