magento2: Undefined constant "MagentoHackathon\Composer\Magento\Deploystrategy\GLOB_BRACE" under Alpine linux
Preconditions and environment
- Magento version 2.4.5
Steps to reproduce
Following official instructions to upgrade 2.4.4 to 2.4.5 https://experienceleague.adobe.com/docs/commerce-operations/upgrade-guide/implementation/perform-upgrade.html
Expected result
Upgraded successfully
Actual result
Composer fails on the composer update step:
In DeploystrategyAbstract.php line 345:
[Error]
Undefined constant "MagentoHackathon\Composer\Magento\Deploystrategy\GLOB_BRACE"
Exception trace:
at /magento/vendor/magento/magento-composer-installer/src/MagentoHackathon/Composer/Magento/Deploystrategy/DeploystrategyAbstract.php:345
MagentoHackathon\Composer\Magento\Deploystrategy\DeploystrategyAbstract->removeContentOfCategory() at /magento/vendor/magento/magento-composer-installer/src/MagentoHackathon/Composer/Magento/Deploystrategy/DeploystrategyAbstract.php:322
MagentoHackathon\Composer\Magento\Deploystrategy\DeploystrategyAbstract->remove() at /magento/vendor/magento/magento-composer-installer/src/MagentoHackathon/Composer/Magento/Deploystrategy/DeploystrategyAbstract.php:92
MagentoHackathon\Composer\Magento\Deploystrategy\DeploystrategyAbstract->clean() at /magento/vendor/magento/magento-composer-installer/src/MagentoHackathon/Composer/Magento/Installer.php:611
MagentoHackathon\Composer\Magento\Installer->update() at phar:///usr/local/bin/composer/src/Composer/Installer/InstallationManager.php:552
Composer\Installer\InstallationManager->update() at phar:///usr/local/bin/composer/src/Composer/Installer/InstallationManager.php:452
Composer\Installer\InstallationManager->Composer\Installer\{closure}() at phar:///usr/local/bin/composer/vendor/react/promise/src/FulfilledPromise.php:28
React\Promise\FulfilledPromise->then() at phar:///usr/local/bin/composer/src/Composer/Installer/InstallationManager.php:453
Composer\Installer\InstallationManager->executeBatch() at phar:///usr/local/bin/composer/src/Composer/Installer/InstallationManager.php:390
Composer\Installer\InstallationManager->downloadAndExecuteBatch() at phar:///usr/local/bin/composer/src/Composer/Installer/InstallationManager.php:282
Composer\Installer\InstallationManager->execute() at phar:///usr/local/bin/composer/src/Composer/Installer.php:763
Composer\Installer->doInstall() at phar:///usr/local/bin/composer/src/Composer/Installer.php:590
Composer\Installer->doUpdate() at phar:///usr/local/bin/composer/src/Composer/Installer.php:279
Composer\Installer->run() at phar:///usr/local/bin/composer/src/Composer/Command/UpdateCommand.php:241
Composer\Command\UpdateCommand->execute() at phar:///usr/local/bin/composer/vendor/symfony/console/Command/Command.php:298
Symfony\Component\Console\Command\Command->run() at phar:///usr/local/bin/composer/vendor/symfony/console/Application.php:1024
Symfony\Component\Console\Application->doRunCommand() at phar:///usr/local/bin/composer/vendor/symfony/console/Application.php:299
Symfony\Component\Console\Application->doRun() at phar:///usr/local/bin/composer/src/Composer/Console/Application.php:335
Composer\Console\Application->doRun() at phar:///usr/local/bin/composer/vendor/symfony/console/Application.php:171
Symfony\Component\Console\Application->run() at phar:///usr/local/bin/composer/src/Composer/Console/Application.php:130
Composer\Console\Application->run() at phar:///usr/local/bin/composer/bin/composer:88
require() at /usr/local/bin/composer:29
Additional information
The official PHP documentation https://www.php.net/manual/en/function.glob.php says:
Note: The GLOB_BRACE flag is not available on some non GNU systems, like Solaris or Alpine Linux.
protected function removeContentOfCategory($sourcePath, $destPath)
{
$sourcePath = preg_replace('#/\*$#', '/{,.}*', $sourcePath);
$matches = glob($sourcePath, GLOB_BRACE);
if ($matches) {
Possible workaround is also discussed here: https://github.com/docker-library/php/issues/719
Release note
No response
Triage and priority
- Severity: S0 - Affects critical data or functionality and leaves users without workaround.
- Severity: S1 - Affects critical data or functionality and forces users to employ a workaround.
- Severity: S2 - Affects non-critical data or functionality and forces users to employ a workaround.
- Severity: S3 - Affects non-critical data or functionality and does not force users to employ a workaround.
- Severity: S4 - Affects aesthetics, professional look and feel, “quality” or “usability”.
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 2
- Comments: 17 (8 by maintainers)
Hello @speller,
Thanks for the report and collaboration!
We have tried to reproduce the issue with the docker image of Alpine Linux. We have pulled the image from its official link as below:
https://hub.docker.com/_/alpine
We have tried to reproduce the issue with a simple PHP script with the use of the
GLOB_BRACEconstant use and we are able to get the actual result as you mentioned in the main description. Please refer to the below screenshot for reference:As in the Magento, we are using this constant in file
DeploystrategyAbstract.phpline number 345 without any checks, we are confirming the issue.Thanks
@engcom-November and @engcom-Hotel
Could you please process this issue?
✅ Jira issue https://jira.corp.adobe.com/browse/AC-6671 is successfully created for this GitHub issue.
@xmav @sidolov @sdzhepa @andrewbess I think it should have p1 priority since that’s the only issue on alpine Linux, and the fix is pretty simple. We even have a pull request with needed changes https://github.com/magento/magento-composer-installer/pull/35 https://github.com/magento/magento-composer-installer/pull/37 (the same changes for different branches)
At the same time, Magento Framework already using
Laminas\Stdlib\Globin all places, so it’s not even adding a new dependency https://github.com/magento/magento2/blob/544f04410d4542f49b1dd1d712f8248a4e497b92/lib/internal/Magento/Framework/Filesystem/Glob.php#L9-L15https://github.com/magento/magento2/search?q=GLOB_BRACE
I would recommend this be increased to S1 as the ability to run composer commands is likely “critical functionality”
Hello,
As I can see this issue got fixed in the scope of the internal Jira ticket AC-6671 by the internal team Related commits: https://github.com/magento/magento-composer-installer/commit/255b3f6b301f65e727c5f7deea63fa43babe4e42
Based on the Jira ticket, the target version is 2.4.6.
Thanks
✅ Confirmed by @engcom-Hotel. Thank you for verifying the issue.
Issue Available: @engcom-Hotel, You will be automatically unassigned. Contributors/Maintainers can claim this issue to continue. To reclaim and continue work, reassign the ticket to yourself.