setup-di-compile | PHP Fatal | Cannot declare class Magento\Framework\Console\Cli
-
31-12-2020 - |
Question
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
Solution
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
Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange