5

While compilation the Magento 2.4.2 experienced following error

Warning: file_put_contents(ProjectName/generated/metadata/primary|global|plugin-list.php): failed to open stream: No such file or directory in ProjectName\vendor\magento\framework\Interception\PluginListGenerator.php on line 414

4 Answers 4

15

To fix above error, kindly follow the below steps

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

Go to line no 414 or find the word “scopePriorityScheme” in PluginListGenerator.php file.

Replace the line

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

This time compilation command, bin/magento setup:di:compile should work

2
  • 4
    in my case: it is on line 158 in magento2.4.1 EE
    – Alam Zaib
    Oct 13, 2021 at 7:07
  • In 2.4.6, its line 156. Same fix.
    – Arfeen
    Sep 25, 2023 at 12:18
4

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

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

with below:

$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.

0

To fix error "In ErrorHandler.php line 61: Warning: file_put_contents(/magento2/generated/metadata/primary|global|plugin-list.php): Failed to o pen stream: No such file or directory in \magento2\vendor\magento\framework\Interception\PluginListG enerator.php on line 414"

Inside function public function write(array $scopes): void of file vendor/magento/framework/Interception/PluginListGenerator.php

Replace the line

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

to

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

After this, I have to execute the below commands to show the content on main website

php bin/magento setup:upgrade
php bin/magento setup:static-content:deploy -f
php bin/magento cache:flush

Hope this will help someone!

0

The error you encountered during compilation in Magento 2.4.2 indicates that the file ProjectName/generated/metadata/primary|global|plugin-list.php could not be created because the directory does not exist. To resolve this issue, you can follow these steps:

  1. Ensure the generated directory exists: Verify that the generated directory exists in the root of your Magento installation. If it doesn't exist, create it manually.

  2. Set proper permissions: Make sure the generated directory and its subdirectories have the correct permissions. You can set the appropriate permissions using the following command:

    chmod -R 777 generated
    

    Note: It's important to ensure the correct ownership and permissions are set according to your server environment. The above command is an example, but you may need to adjust it based on your specific server configuration.

  3. Clear the generated code: Remove any existing generated code files to ensure a clean regeneration process. You can use the following command:

    rm -rf generated/*
    
  4. Recompile your code: Now, recompile your Magento code by running the following command:

    bin/magento setup:di:compile
    

    This command will regenerate the necessary files, including the plugin-list.php file that was causing the error.

  5. Verify the issue is resolved: After the compilation process completes, check if the error is resolved. If the plugin-list.php file is successfully generated, the compilation process should complete without any warnings or errors.

By following these steps, you should be able to resolve the error related to the missing plugin-list.php file during the compilation process in Magento 2.4.2.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.