Magento 2 Setup di Compile Problem

The question:

After I upgraded to Magento 2.3, running the command setup:di:compile, I get this error:

Area configuration aggregation... 5/7 [====================>-------]  71% 58 
secs 276.0 MiB
In ClassReader.php line 35:

  Class MagentoEmailModelSourceVariables does not exist

In ClassReader.php line 29:

   Class MagentoEmailModelSourceVariables does not exist

setup:di:compile

I’ve checked the database setup_module to ensure no mismatch or missing scheme/data versions but all are ok.

The Solutions:

Below are the methods you can try. The first solution is probably the best. Try others if the first one doesn’t work. Senior developers aren’t just copying/pasting – they read the methods carefully & apply them wisely to each case.

Method 1

Search for the missing class in your magento2 code, you can do via linux cli:

find /path/to/magento2-root -type f -iname '*.php' -print0 | xargs -0 grep -nw -e 'Magento\Email\Model\Source\Variables'

and comment any line calling this class (that was removed from magento2.3)

UPDATE

You can also change this class in Magento 2.3 for MagentoVariableModelSourceVariables

Method 2

I just replaced the class MagentoEmailModelSourceVariables with MagentoVariableModelSourceVariables.

Method 3

Class BssHtmlSiteMapModelFilter

public function __construct(
    ...  
    MagentoEmailModelSourceVariables $configVariables,
    ...
)

replace

public function __construct(
    ...  
    MagentoVariableModelSourceVariables $configVariables,
    ...
)

Method 4

Dirty Hack

Rename registration.php file of module which is causing problem for compilation.

😉

Method 5

Have you used any SMTP extension? If yes then please remove that and then try to run the command :

php bin/magento setup:di:compile

If your issue is resolved then install 2.3 compatible SMTP extension.

Method 6

Clear your generated folder and run the compile command.

rm -rf generated/*

Then run the compile command

bin/magento setup:di:compile

Method 7

If you use any custom extensions, check the compatibility with Magento 2.3

All extensions that are not compatible must be removed, for example, Mageplaza smtp was not compatible and Mageworx CEO tool is was also not compatible.

After then run below command: php bin/magent setup:di:compile


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

Leave a Comment