paketo-buildpacks / composer

Apache License 2.0
0 stars 2 forks source link

Buildpack does not detect that openssl is a required extension #27

Open fg-j opened 2 years ago

fg-j commented 2 years ago

Relocating issue from archived repo: https://github.com/paketo-buildpacks/php-composer/issues/190

till commented 1 year ago

This is interesting. @fg-j are you saying the buildpack would attempt to create the custom.ini file automatically? That would be great, but it doesn't seem to be working.

I just tested this (unknowingly) with a Symfony demo app:

symfony new . --demo

When I try to build this with pack (and hopefully all the latest buildpacks), there are errors on the composer install step and I have to supply (at minimum) a .php.ini.d/custom.ini with the following:

extension="mbstring.so"
extension="pdo.so"
extension="pdo_sqlite.so"

This is the error which suggests the setup didn't happen:

[builder] Paketo Composer Install Buildpack 0.1.2
[builder]   Executing build process
[builder]   Building new layer /layers/paketo-buildpacks_composer-install/composer-packages
[builder]   Running 'composer install'
[builder]     Installing dependencies from lock file (including require-dev)
[builder]     Verifying lock file contents can be installed on current platform.
[builder] exit status 2
[builder]     Your lock file does not contain a compatible set of packages. Please run composer update.
[builder]     
[builder]       Problem 1
[builder]         - Root composer.json requires PHP extension ext-pdo_sqlite * but it is missing from your system. Install or enable PHP's pdo_sqlite extension.
[builder]       Problem 2
[builder]         - doctrine/orm is locked to version 2.10.2 and an update of this package was not requested.
[builder]         - doctrine/orm 2.10.2 requires ext-pdo * -> it is missing from your system. Install or enable PHP's pdo extension.
[builder]       Problem 3
[builder]         - league/commonmark is locked to version 2.1.0 and an update of this package was not requested.
[builder]         - league/commonmark 2.1.0 requires ext-mbstring * -> it is missing from your system. Install or enable PHP's mbstring extension.
[builder]       Problem 4
[builder]         - doctrine/orm 2.10.2 requires ext-pdo * -> it is missing from your system. Install or enable PHP's pdo extension.
[builder]         - doctrine/doctrine-fixtures-bundle 3.4.1 requires doctrine/orm ^2.6.0 -> satisfiable by doctrine/orm[2.10.2].
[builder]         - doctrine/doctrine-fixtures-bundle is locked to version 3.4.1 and an update of this package was not requested.
[builder]     
[builder]     To enable extensions, verify that they are enabled in your .ini files:
[builder]         - /layers/paketo-buildpacks_composer-install/composer-php-ini/composer-php.ini
[builder]         - /layers/paketo-buildpacks_php-dist/php/etc/buildpack.ini
[builder]         - /layers/paketo-buildpacks_php-dist/php/etc/php.ini
[builder]         - /layers/paketo-buildpacks_php-dist/php/etc/buildpack.ini
[builder]         - /layers/paketo-buildpacks_php-dist/php/etc/php.ini
[builder]     You can also run `php --ini` in a terminal to see which files are used by PHP in CLI mode.
[builder]     Alternatively, you can run Composer with `--ignore-platform-req=ext-pdo_sqlite --ignore-platform-req=ext-pdo --ignore-platform-req=ext-mbstring --ignore-platform-req=ext-pdo` to temporarily ignore these required extensions.
[builder] ERROR: failed to build: exit status 1

Once I add my own custom.ini, I get further but then it fails with:

[builder] 
[builder] Paketo Composer Install Buildpack 0.1.2
[builder]   Executing build process
[builder]   Building new layer /layers/paketo-buildpacks_composer-install/composer-packages
[builder]   Running 'composer install'
[builder]   Ran 'composer install --no-progress --no-autoloader --no-scripts'
[builder]   Writing symlink /workspace/vendor => /layers/paketo-buildpacks_composer-install/composer-packages/vendor
[builder]   Running 'composer dump-autoload'
[builder]   Ran 'composer dump-autoload --classmap-authoritative'
[builder]       Completed in 47.203s
[builder] 
[builder]   Generating SBOM for /layers/paketo-buildpacks_composer-install/composer-packages
[builder]       Completed in 6.285s
[builder] 
[builder]   Running 'composer check-platform-reqs'
[builder]     Deprecation Notice: Return type of Symfony\Flex\Response::jsonSerialize() should either be compatible with JsonSerializable::jsonSerialize(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /layers/paketo-buildpacks_composer-install/composer-packages/vendor/symfony/flex/src/Response.php:68
[builder]     Checking platform requirements for packages in the vendor dir
[builder]     composer-plugin-api   2.3.0                                                         success  
[builder]     composer-runtime-api  2.2.2                                                         success  
[builder]     ext-ctype             8.1.7                                                         success  
[builder]     ext-dom               20031129                                                      success  
[builder]     ext-libxml            8.1.7                                                         success  
[builder]     ext-mbstring          8.1.7                                                         success  
[builder]     ext-pdo               8.1.7                                                         success  
[builder]     ext-pdo_sqlite        8.1.7                                                         success  
[builder]     ext-tokenizer         8.1.7                                                         success  
[builder]     ext-xml               8.1.7                                                         success  
[builder]     php                   8.1.7     laminas/laminas-code requires php (^7.4 || ~8.0.0)  failed   
[builder] exit status 1
[builder] ERROR: failed to build: exit status 1

Confusing that the detection step comes after a successful install?

Also not sure if this is actually working as it is supposed to:

❯ /usr/local/opt/php@8.1/bin/php /usr/local/bin/composer check-platform-reqs
Deprecation Notice: Return type of Symfony\Flex\Response::jsonSerialize() should either be compatible with JsonSerializable::jsonSerialize(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /Users/till/example-symfony-webapp/vendor/symfony/flex/src/Response.php:68
Checking platform requirements for packages in the vendor dir
composer-plugin-api  2.3.0                                                                                                                          success 
composer-runtime-api 2.2.2                                                                                                                          success 
ext-ctype            8.1.9                                                                                                                          success 
ext-dom              20031129                                                                                                                       success 
ext-libxml           8.1.9                                                                                                                          success 
ext-mbstring         8.1.9                                                                                                                          success 
ext-pdo              8.1.9                                                                                                                          success 
ext-pdo_sqlite       8.1.9                                                                                                                          success 
ext-tokenizer        8.1.9                                                                                                                          success 
ext-xml              8.1.9                                                                                                                          success 
php                  8.1.9    laminas/laminas-code requires php ([>= 7.4.0.0-dev < 8.1.0.0-dev]) laminas/laminas-code requires php (^7.4 || ~8.0.0) failed  

~/example-symfony-webapp main
❯ /usr/local/opt/php@8.1/bin/php /usr/local/bin/composer install --no-dev --no-scripts
Deprecation Notice: Return type of Symfony\Flex\Response::jsonSerialize() should either be compatible with JsonSerializable::jsonSerialize(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /Users/till/example-symfony-webapp/vendor/symfony/flex/src/Response.php:68
Installing dependencies from lock file
Verifying lock file contents can be installed on current platform.
Package operations: 0 installs, 0 updates, 12 removals
  - Removing symfony/web-profiler-bundle (v6.0.1)
  - Removing symfony/phpunit-bridge (v6.0.0)
  - Removing symfony/maker-bundle (v1.36.4)
  - Removing symfony/dom-crawler (v6.0.1)
  - Removing symfony/debug-bundle (v6.0.0)
  - Removing symfony/css-selector (v6.0.1)
  - Removing symfony/browser-kit (v6.0.1)
  - Removing phpstan/phpstan (1.2.0)
  - Removing nikic/php-parser (v4.13.2)
  - Removing doctrine/doctrine-fixtures-bundle (3.4.1)
  - Removing doctrine/data-fixtures (1.5.1)
  - Removing dama/doctrine-test-bundle (v6.7.1)
Generating autoload files
composer/package-versions-deprecated: Generating version class...
composer/package-versions-deprecated: ...done generating version class
76 packages you are using are looking for funding.
Use the `composer fund` command to find out more!

Run composer recipes at any time to see the status of your Symfony recipes.