What to Do If setup:di:compile Fails in Magento2

compilationmagento2

I'm trying to understand what particular impact may have a problem I'm facing with when deploying a Magento 2 project.

I run a set of commands in order to update the website and refresh/reindex/update all caches and data.

cd /var/www/sites/php7m2/httpdocs/magento;
n98-magerun2.phar db:query "update core_config_data set value='http://magento.%vm%.php7m2.ci1.interactivated.me/' where path like '%base_url%'";

git pull origin;
git checkout %branch%;

git diff --name-only %branch% master;

rm -rf /var/www/sites/php7m2/httpdocs/magento/var/di;
php -f bin/magento setup:upgrade;
php -dmemory-limit=2G bin/magento setup:di:compile;

for command in \$(git diff --name-only master %branch% | grep Console); do command_code=\$(basename \$command); filename="\${command_code%.*}"; echo \$filename; php bin/magento interactivated:shell \$filename; done;

bin/magento setup:static-content:deploy nl_NL;

n98-magerun2.phar cache:clean;

And it fails on the step where I'd perform compilation:

$ php -dmemory_limit=-1 ./magento setup:di:compile
Compilation was started.
Repositories code generation... 1/7 ====>----------------------- 14% 1 sec 66.0 MiB
PHP Fatal error: Class 'Google_IO' not found in app/code/Magecheckout/SocialLogin/Model/Google/Oauth2/io/Google_CurlIO.php on line 27

So my questions here are:
1. is the command "setup:di:compile" meant to be run mandatory whenever an update of the site is performed?
2. what should be done with this problem? Does it have to be fixed or it's not a problem if the files were not compiled?
3. is the set of commands is generally correct? Just guessing if I'm doing things in wrong order or something like this.

Best Answer

1) Well its not mandatory to run setup:di:compile command everytime but if you have done any code change specially with factory methods ,proxy, js changes or any code compilation then you must need to run this command.

2) Right now problem is in your SocialLogin MODULE which you have configure and located in app/code as have installed it for social login but it requires Google_IO class at somewhere and you forgot to give it. so its get fatal error

  • You can resolve it by adding Google_IO class or by delete this module from app/code directory and run setup:upgrade command

3) Yes set of commands are correct , you can use cache:clean , cache:flush , indexer:reindex and sometimes when needed setp:di:compile command

when you run setup:di:compile command it do below things

  • Code compilation consists of all of the following in no particular order:
  • Application code generation (factories, proxies, and so on)
  • Area configuration aggregation (that is, optimized dependency injection configurations per area)

  • Interceptor generation (that is, optimized code generation of interceptors)

  • Interception cache generation Repositories code generation (that is, generated code for APIs)

  • Service data attributes generation (that is, generated extension
    classes for data objects)

For more reference refer this link - http://devdocs.magento.com/guides/v2.0/config-guide/cli/config-cli-subcommands-compiler.html

Related Topic