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:\xampp\htdocs\Yash\mag241sample\vendor\magento\framework\Interception\PluginListGenerator.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.
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
- Open PluginListGenerator.php file located at vendor/magento/framework/Interception.
- Replace the line
1$cacheId = implode('|', $this->scopePriorityScheme) . "|" . $this->cacheId;
1$cacheId = implode('-', $this->scopePriorityScheme) . "-" . $this->cacheId; - Save the PluginListGenerator.php file.
Now your “bin/magento setup:di:compile” command will run successfully without any error.
That’s it!
If you have any question regarding this error or its solution, feel free to mention them in the Comments section below.
I’m here to help you out.
Do share the solution with Magento Community via social media.
Thank You.
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 businesses seeking to optimize their online stores. He loves sharing technical solutions related to Magento 2 & Shopify.
6 Comments
Hello, I tried your solution and the error no longer appears! However, when I try to login to the Magento Admin panel the page refreshes and nothing happens. I can’t login until I undo the change done to the code.
Hello Ashraf,
The above solution can be helpful in the local and it is working properly from our end.
Thank You
Deprecated Functionality: The behavior of unparenthesized expressions containing both ‘.’ and ‘+’/’-‘ will change in PHP 8: ‘+’/’-‘ will take a higher precedence in C:xampp7htdocsmagento-communtiyvendormagentoframeworkInterceptionPluginListGenerator.php on line 159
even the updated code is throwing an error now. got stuck with this today.
Hello Rohit,
The above code is compatible with Magento 2.4.1 and PHP 7.4 is supported in this version.
Thank You
Go to line 414 or find the word “scopePriorityScheme” in the PluginListGenerator.php file.
scopePriorityScheme not getting at line number 414.
that is getting at the 158 line number.
Hello Vishal,
Thanks for drawing my attention, please check the updated blog post.
Thanks.