1

When I try to run command setup:di:compile I get the following error:

[http]$ php-7.0 bin/magento setup:di:compile
The directory "/microcloud/domains/operm2/domains/domainname.co.uk/http/var/generation/Magento" cannot be deleted Warning!rmdir(/microcloud/domains/operm2/domains/domainname.co.uk/http/var/generation/Magento): Directory not empty#0 /microcloud/domains/operm2/domains/domainname.co.uk/http/vendor/magento/framework/Filesystem/Driver/File.php(403): Magento\Framework\Filesystem\Driver\File->deleteDirectory('/microcloud/dom...')
#1 /microcloud/domains/operm2/domains/domainname.co.uk/http/setup/src/Magento/Setup/Console/CompilerPreparation.php(68): Magento\Framework\Filesystem\Driver\File->deleteDirectory('/microcloud/dom...')
#2 /microcloud/domains/operm2/domains/domainname.co.uk/http/vendor/magento/framework/Console/Cli.php(74): Magento\Setup\Console\CompilerPreparation->handleCompilerEnvironment()
#3 /microcloud/domains/operm2/domains/domainname.co.uk/http/bin/magento(22): Magento\Framework\Console\Cli->__construct('Magento CLI')
#4 {main}

PHP Fatal error:  Cannot declare class Magento\Framework\Console\Cli, because the name is already in use in /microcloud/domains/operm2/domains/domainname.co.uk/http/Cli.php on line 0

Fatal error: Cannot declare class Magento\Framework\Console\Cli, because the name is already in use in /microcloud/domains/operm2/domains/domainname.co.uk/http/Cli.php on line 0

Anyone came across this before? Running Magento ver. 2.1.8

  • as a fast fix: have you deleted the contents of var/generation, var/di and tried again? – simonthesorcerer Feb 16 '18 at 18:53
  • Yes, that's working but once I regenerate the files in those directories, again the compilation fails so I'm looking for a solution rather than a quick fix :/ Thank you for your interest! – Greg Feb 16 '18 at 18:59
  • The first error is that a directory can not be deleted. Have you checked read/write permissions of your php user? – simonthesorcerer Feb 16 '18 at 19:02
1

This is file permission / file ownership error. Basically the user that you are running setup:di:compile doesn't have the right permission to perform the code regeneration.

Please follow the dev doc for the correct settings:

http://devdocs.magento.com/guides/v2.1/install-gde/prereq/file-system-perms.html

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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