Published: May 6, 2020
Last updated:

[M1] cache_dir “null” must be a directory

Note: We are seeing drastic increase in such error reports since April 27, 2020 after recent cPanel update. You are also may be interested in Wrong format… missing 0 – error on catalog pages
Exception error is printed in Magento Backend on attempt to navigate to any page, i.e. Sales > Orders. Standard “Exception printing is disabled by default for security reasons” error is shown and corresponding file under var/report states the following error:
"cache_dir "null" must be a directory"

Cause

Cause can be some server-side update, incorrectly set TEMP_DIR variable or wrong permissions on var/ or var/tmp.

Solution

To definitely resolve this issue try all of the following steps:
  • ensure that var/tmp directory exists under Magento root directory and is writeable for webserver:
    $ mkdir -p var/tmp
    $ chmod 1777 var/tmp
    
  • create local override for Zend/Cache/Backend/File.php if it does not exists yet (otherwise simply skip this step):
    $ ls -la app/code/local/Zend/Cache/Backend/File.php
    ls: cannot access app/code/local/Zend/Cache/Backend/File.php: No such file or directory
    $ mkdir -p app/code/local/Zend/Cache/Backend
    $ cp -a lib/Zend/Cache/Backend/File.php app/code/local/Zend/Cache/Backend/ 
    
  • edit app/code/local/Zend/Cache/Backend/File.php setting cache_dir manually:
    --- lib/Zend/Cache/Backend/File.php
    +++ app/code/local/Zend/Cache/Backend/File.php
    @@ -96,7 +96,7 @@
          * @var array available options
          */
         protected $_options = array(
    -        'cache_dir' => 'null',
    +        'cache_dir' => 'var/tmp/',
             'file_locking' => true,
             'read_control' => true,
             'read_control_type' => 'crc32',
    
    
  • flush compiled code and Disable Magento Compiler to apply changes.


Note: We are seeing drastic increase in such error reports since April 27, 2020 after recent cPanel update. You are also may be interested in Wrong format… missing 0 – error on catalog pages

Posted in: Troubleshooting

15 votes, 5.00 avg. rating (98% score)