Showing results for 
Search instead for 
Did you mean: 

Compiling stops at 44%

Compiling stops at 44%

I'm in the process of migrating a Magento 2 install to AWS, and have been running into an issue when running the command:

php bin/magento setup:di:compile



When running the command, the compiling process stops at 44% and outputs the following errors:


In Generator.php line 140:

  Class Pelago\Emogrifier does not exist
  Class Bss\HtmlSiteMap\Model\Filter\Interceptor generation error: The requested class did not generate properly, because the 'generated' directory permission is read-
  only. If --- after running the 'bin/magento setup:di:compile' CLI command when the 'generated' directory permission is set to write --- the requested class did not g
  enerate properly, then you must add the generated class object to the signature of the related construct method, only.



Things I've tried:

  1. Ran the command as both root and site user
  2. Changed the permissions for /generated/* and var/* to 777 (as a test)
  3. Chown /generated/* and var/* to site user
  4. Ran composer update
  5. Cleared/flushed Magento cache


And none of the above has worked. Any ideas would be greatly appreciated!



Re: Compiling stops at 44%

Verify whether the Namespace of the "Pelago\Emogrifier" class is accurate.


Afterward, confirm if the class aligns with the one stated within "Pelago\Emogrifier".


Rectifying the contextual namespace within `Pelago\Emogrifier` will effectively address the problem.

Re: Compiling stops at 44%


The error message you're encountering while running php bin/magento setup:di:compile in Magento 2 suggests that there's an issue with class generation, particularly related to the class Pelago\Emogrifier and the Bss\HtmlSiteMap\Model\Filter\Interceptor.

Here are some steps you can take to troubleshoot and resolve this issue:

  1. Check for Missing Dependencies:

    • Ensure that you have installed all required dependencies for your Magento 2 project using Composer. If you haven't already, run composer install or composer update from the Magento root directory to make sure all required packages are installed.
  2. Check Autoloader Configuration:

    • Make sure that your Composer autoloader is correctly configured. Ensure that the vendor/autoload.php file exists and is up-to-date. You might want to try deleting the vendor directory and composer.lock file and then running composer install again.
  3. Clear Generated Code:

    • Delete the contents of the generated directory and the contents of the var/cache directory. You can do this manually or by running:


rm -rf generated/* var/cache/*



  1. Check File Permissions:

    • Ensure that the web server user has write permissions for the generated and var directories. You mentioned changing permissions to 777, but it's not recommended for security reasons. Instead, you can grant ownership to the web server user or group.
      chown -R web-server-user:web-server-group generated var
  2. Check for Compilation Errors:

    • Review the specific error messages related to the class generation process. It's possible that there are issues with the code in the classes being generated. Look for any fatal errors or issues in the mentioned classes. You may need to manually review and correct the code in these classes.
  3. Check for Missing/Deleted Files:

    • Ensure that the Pelago\Emogrifier class and the Bss\HtmlSiteMap\Model\Filter\Interceptor class actually exist in your codebase. Sometimes, files may be missing or accidentally deleted.
  4. Magento Mode:

    • Ensure that you are running the setup:di:compile command in the correct mode (e.g., production or developer) by setting the mode using bin/magento deploy:mode:set.
  5. Third-Party Modules:

    • If the Pelago\Emogrifier and Bss\HtmlSiteMap\Model\Filter\Interceptor classes are related to third-party modules, make sure these modules are correctly installed and configured. It's possible that a module is not installed or enabled correctly.
  6. Magento Version Compatibility:

    • Verify that the versions of Magento, third-party modules, and PHP are compatible with each other. Sometimes, incompatibilities between components can lead to compilation issues.
  7. Logs and Debugging:

    • Check the Magento logs in var/log for any additional error messages that might provide more details about the issue.