cancel
Showing results for 
Search instead for 
Did you mean: 

Magento 2.3 - During run the command setup:di:compile production site getting error

Magento 2.3 - During run the command setup:di:compile production site getting error

If added new extension, run setup:di:compile my whole site error showing following on screen,


Fatal error: Uncaught Zend_Cache_Exception: cache_dir "/var/www/html/test/var/cache/" is not writable in /var/www/html/test/vendor/magento/zendframework1/library/Zend/Cache.php:209 Stack trace: #0 /var/www/html/test/vendor/magento/zendframework1/library/Zend/Cache/Backend/File.php(180): Zend_Cache::throwException('cache_dir "/var...') #1 /var/www/html/test/vendor/colinmollenhour/cache-backend-file/File.php(87): Zend_Cache_Backend_File->setCacheDir('/var/www/html/g...') #2 /var/www/html/test/vendor/magento/zendframework1/library/Zend/Cache.php(153): Cm_Cache_Backend_File->__construct(Array) #3 /var/www/html/test/vendor/magento/zendframework1/library/Zend/Cache.php(94): Zend_Cache::_makeBackend('Cm_Cache_Backen...', Array, true, true) #4 /var/www/html/test/lib/internal/Magento/Framework/App/Cache/Frontend/Factory.php(156): Zend_Cache::factory('Magento\\Framewo...', 'Cm_Cache_Backen...', Array, Array, true, true, true) #5 /var/www/html/test/lib/internal/Magento/Framework/Cache/Frontend/Adapter/Zend.ph in /var/www/html/test/vendor/magento/zendframework1/library/Zend/Cache.php on line 209

 

Note : After give the permission the issue solved, but how to avoid this error on live site.

2 REPLIES 2

Re: Magento 2.3 - During run the command setup:di:compile production site getting error

Hello @Aveeva 

 

When new files are created in var/cache/, they are not automatically set to 777 so it's a part of deployment process to give permission to few folders which gets updated by commands or compilation process :

1. var

2. generated

3. pub/static/

4. pub/media/

 

so what I generally do is, I have created one pipeline of commands for deployment, you can create a file "deploy.sh" with this content :

chmod -R 777 var/ generated/ pub/media/ pub/static/
php bin/magento setup:upgrade
php bin/magento setup:di:compile
php bin/magento setup:static-content:deploy -f
php bin/magento c:f
chmod -R 777 var/ generated/ pub/media/ pub/static/

so whenever there is a big change we redeploy everything by running :

sh deploy.sh

If you don't want to give permission, you can take a look for sticky bit if suitable for you, but the ideal approach which I think is the above I mentioned.

 

Hope it helps !

Problem Solved ? Click on 'Kudos' & Accept as Solution ! Smiley Happy

Re: Magento 2.3 - During run the command setup:di:compile production site getting error

Hi @Aveeva 

 

For immediate solution, you can run below command:

sudo chmod 777 -R var/cache
 
It may help you!
Problem Solved? Please click on 'Kudos' & Accept as Solution!
Problem solved? Click Accept as Solution!