Critical Bug Alert: Magento 2.4.9 Breaks CLI on Alpine Linux – The GLOB_BRACE Mystery Unraveled
Critical Bug Alert: Magento 2.4.9 Breaks CLI on Alpine Linux – The GLOB_BRACE Mystery Unraveled
The Magento 2.4.9 release has introduced a significant hurdle for developers and merchants leveraging Alpine Linux in their CI/CD pipelines and Docker environments. A critical bug, tracked as Issue #41066, renders all bin/magento commands completely non-functional on musl-based PHP builds, commonly found in Alpine Docker images. This means essential operations like setup:di:compile and setup:static-content:deploy are impossible, effectively breaking deployments and development workflows.
The Problem: Undefined Constant GLOB_BRACE
Users attempting to run any Magento CLI command on an Alpine-based PHP environment with Magento Open Source 2.4.9 will encounter a fatal error during bootstrap:
There is an error in vendor/magento/framework/Setup/Mvc/MvcApplication.php at line: 170
Undefined constant "Magento\Framework\Setup\Mvc\GLOB_BRACE"
#0 vendor/magento/framework/Setup/Mvc/MvcApplication.php(123): Magento\Framework\Setup\Mvc\MvcApplication::loadAutoloadConfig()
#1 setup/src/Magento/Setup/Application.php(29): Magento\Framework\Setup\Mvc\MvcApplication::init()
#2 vendor/magento/framework/Console/Cli.php(99): Magento\Setup\Application->bootstrap()
#3 bin/magento(22)
This error stems from the PHP glob() function being called with the GLOB_BRACE constant. While GLOB_BRACE is standard on glibc-based systems (like Ubuntu, Debian, CentOS), it is not defined in musl libc, which Alpine Linux uses. Consequently, PHP builds linked against musl libc do not have this constant available, leading to the "Undefined constant" error.
Root Cause: A Regression from "Laminas MVC Retiring"
The issue is a regression introduced by the AC-15068 initiative, which aimed at "Laminas MVC Retiring." As part of this, the setup application was refactored from laminas-mvc to Magento\Framework\Setup\Mvc\MvcApplication. Unfortunately, this change replaced the use of Laminas\Stdlib\Glob (which provided a userland brace-expansion fallback for environments lacking GLOB_BRACE) with a direct call to PHP's native glob($globPath, GLOB_BRACE). This inadvertently reintroduced a bug first seen in 2015 (Issue #2130), which was originally solved by utilizing the Zend/Laminas glob wrapper.
Impact on Development and CI/CD Pipelines
For any Magento project relying on Alpine Linux for its Docker containers, particularly in CI/CD environments, this bug is a showstopper. Without functional bin/magento commands, critical build steps like dependency injection compilation and static content deployment cannot proceed. This makes Magento Open Source 2.4.9 effectively unusable out-of-the-box on such common and resource-efficient platforms.
The Solution and Immediate Workaround
The good news is that the Magento core team has already addressed this issue in the 2.4-develop branch with commits like af2603bc8e and 9ce24a8db8, which re-implement the use of Magento\Framework\Filesystem\Glob::glob(). The community's request is for this crucial fix to be backported to the 2.4.9 patch line (e.g., 2.4.9-p1) to resolve the immediate crisis.
Until an official patch is released, affected users can implement a workaround using cweagans/composer-patches. The following patch can be applied to magento/framework:
--- a/Setup/Mvc/MvcApplication.php
+++ b/Setup/Mvc/MvcApplication.php
@@ -167,7 +167,7 @@
// Load global.php and local.php configurations from config_glob_paths
if (isset($configuration['module_listener_options']['config_glob_paths'])) {
foreach ($configuration['module_listener_options']['config_glob_paths'] as $globPath) {
- $files = glob($globPath, GLOB_BRACE);
+ $files = \Laminas\Stdlib\Glob::glob($globPath, \Laminas\Stdlib\Glob::GLOB_BRACE);
foreach ($files as $file) {
This patch reverts the problematic direct glob() call to use Laminas\Stdlib\Glob::glob(), which correctly handles the brace expansion on musl-based systems.
Conclusion
This critical bug highlights the challenges in maintaining compatibility across diverse environments. While the fix is already in the development branch, its absence in the current 2.4.9 release impacts a significant portion of the Magento community relying on Alpine Linux for efficient containerized deployments. Applying the provided composer patch is essential for anyone currently stuck with this issue, ensuring their Magento 2.4.9 CLI commands function as expected.