Solved: Failed to Open Stream Error While Compiling PluginListGenerator.php in Magento 2.4.1

Magento 2 is a preferable choice for E-commerce stores serving the global customer base, owing to the flexibility and customization options.

Magento releases upgraded versions to improve the store performance and it is highly recommended to upgrade to the latest Magento 2 version.

However, sometimes the developers face errors while migrating, upgrading, customizing or performing any operations on the Magento 2 store.

One of them is failed to open stream error while compiling PluginListGenerator.php in Magento 2.4.1 that says,

file_put_contents(C:/xampp/htdocs/Yash/mag241sample/generated/metadata/primary|global|plugin-list.php): failed to open stream: No such file or directory in C:xampphtdocsYashmag241samplevendormagentoframeworkInterceptionPluginListGenerator.php on line 414

You may face this error while running the command “bin/magento setup:di:compile” in Magento 2.4.1 using XAMPP.

Error while compile

This error may also occur after upgrading your Magento 2 from an older version to Magento 2.4.1.

Check the solution for the same below:

Solution for Failed to Open Stream Error While Compiling PluginListGenerator.php in Magento 2.4.1

1. Open PluginListGenerator.php file located at vendor/magento/framework/Interception.

2. Replace the line

$cacheId = implode('|', $this->scopePriorityScheme) . "|" . $this->cacheId;

with below:

$cacheId = implode('-', $this->scopePriorityScheme) . "-" . $this->cacheId;

3. Save the PluginListGenerator.php file.

Now your “bin/magento setup:di:compile” command will run successfully without any error.

That’s it!

Do share the solution with Magento Community via social media.

Thank You.

Sanjay Jethva

Article by

Sanjay Jethva

Sanjay is the co-founder and CTO of Meetanshi with hands-on expertise with Magento since 2011. He specializes in complex development, integrations, extensions, and customizations. Sanjay is one the top 50 contributor to the Magento community and is recognized by Adobe. His passion for Magento 2 and Shopify solutions has made him a trusted source for...