Someone changed my php version for my magento 2 website to 5.6 and I changed it back to 7.0 and now I'm getting this error when I try to run the major magento commands such as compile and system:upgrade
The file "/var/www/vhosts/ooples.com/httpdocs/var/generation/Composer/Console/ApplicationFactory.php"
cannot be deleted
Warning!unlink(/var/www/vhosts/ooples.com/httpdocs/var/generation/Composer/Console/ApplicationFactory.php):
Permission denied#0
/var/www/vhosts/ooples.com/httpdocs/lib/internal/Magento/Framework/Filesystem/Driver/File.php(405):
Magento\Framework\Filesystem\Driver\File->deleteFile('/var/www/vhosts…')
1 /var/www/vhosts/ooples.com/httpdocs/lib/internal/Magento/Framework/Filesystem/Driver/File.php(403):
Magento\Framework\Filesystem\Driver\File->deleteDirectory('/var/www/vhosts…')
2 /var/www/vhosts/ooples.com/httpdocs/lib/internal/Magento/Framework/Filesystem/Driver/File.php(403):
Magento\Framework\Filesystem\Driver\File->deleteDirectory('/var/www/vhosts…')
3 /var/www/vhosts/ooples.com/httpdocs/setup/src/Magento/Setup/Console/CompilerPreparation.php(68):
Magento\Framework\Filesystem\Driver\File->deleteDirectory('/var/www/vhosts…')
4 /var/www/vhosts/ooples.com/httpdocs/lib/internal/Magento/Framework/Console/Cli.php(74):
Magento\Setup\Console\CompilerPreparation->handleCompilerEnvironment()
5 /var/www/vhosts/ooples.com/httpdocs/bin/magento(22): Magento\Framework\Console\Cli->__construct('Magento CLI')
6 {main}PHP Fatal error: Uncaught Error: Class 'Cli' not found in
/var/www/vhosts/ooples.com/httpdocs/bin/magento:31 Stack trace:
0 {main} thrown in /var/www/vhosts/ooples.com/httpdocs/bin/magento on line 31Fatal error: Uncaught Error: Class 'Cli' not found in
/var/www/vhosts/ooples.com/httpdocs/bin/magento:31 Stack trace:
0 {main} thrown in /var/www/vhosts/ooples.com/httpdocs/bin/magento on line 31
What can I do to fix this error?
UPDATE: Here are the results when I run rm -rf var
rm: cannot remove ‘var/di/setup.ser’: Permission denied
rm: cannot remove ‘var/di/webapi_rest.ser’: Permission denied
rm: cannot remove ‘var/di/frontend.ser’: Permission denied
rm: cannot remove ‘var/di/global.ser’: Permission denied
rm: cannot remove ‘var/di/adminhtml.ser’: Permission denied
rm: cannot remove ‘var/di/crontab.ser’: Permission denied
rm: cannot remove ‘var/di/webapi_soap.ser’: Permission denied
Best Answer
This error has nothing to do with Plesk it's from the Magento script itself. Whoever wrote it clearly has no idea of PHP OOP. Sorry but it's true.
There's nowhere to be found an "use" keyword in the script but you can clearly see that he's trying to use
class without specifying the namespace. That's the whole error if you change it to
it will work.
Change the
bin/magento
shell file from:to
Take a look at the exit at the end...
Sorry if I offended somebody ;]