Magento: 2.1.6
PHP: 5.6.26
MySQL: 14.14 Distrib 5.7.15
rm -rf var/generation/*
rm: cannot remove `var/generation/Magento': Directory not empty
But I can remove the folder to another folder and then delete it.
This error causes PHP Fatal error: Class 'Cli' not found in /magento2/bin/magento on line 31 then I trying to bin/magento setup:di:compile
All permissions are configured as described in document
Is the site taking traffic when you're doing the rm -rf ?
@choukalos
Then I am trying to delete, website is online and maintanence mode is disabled. I guess there is a traffic, does it relate?
The var/generation folder contains PHP files that are used by Magento2 when running (which includes users visiting your website while it's online). If you're running in production mode, then there's also var/di.
Thus it is preferable to put the site into maintenance mode for the time of flushing and rebuilding the var/di and var/generation folders.
If you're worried about downtime, you could generate these files on a staging environment and then simply copy to the production (assuming both are running on the very same version of source code).
@Tonop, thank you for your report.
This seems to be correct Magento behavior. Please refer to the Community Forums or the Magento Stack Exchange site for advice or general discussion about this.
Otherwise you may submit Pull Request with the suggested changes.
I have put my site into maintenance mode and I still couldn't remove var/generation/Magento for these folders:
Backend
Config
Framework
Store
Translation
Since I upgrade from 2.1.0 to 2.1.9 I experienced some strange issues and this is one of them.
@Tonop, thank you for your report.
This seems to be correct Magento behavior. Please refer to the Community Forums or the Magento Stack Exchange site for advice or general discussion about this.
Otherwise you may submit Pull Request with the suggested changes.
Most helpful comment
Is the site taking traffic when you're doing the rm -rf ?