Daan B.
Daan B.

Reputation: 65

Message: cache_dir must be a directory

Hello people I have some problems with Zend Framework.
I first got the following message: Message:
Could not determine temp directory, please specify a cache_dir manually.
I searched google and found this post: Zend Framework : Could not determine temp directory, please specify a cache_dir manually
I read it and now when I fill in the form I get the following error:
(Everywhere where I put .. in the error means the domain.)

Message: cache_dir must be a directory

- #0 /home/daan/domains/../library/Zend/Cache/Backend/File.php(154): Zend_Cache::throwException('cache_dir must ...')
 - #1 /home/daan/domains/../library/Zend/Cache/Backend/File.php(121): Zend_Cache_Backend_File->setCacheDir('/domains/daan.h...')
 - #2 /home/daan/domains/../library/Zend/Cache.php(153): Zend_Cache_Backend_File->__construct(Array)
 - #3 /home/daan/domains/../library/Zend/Cache.php(94): Zend_Cache::_makeBackend('File', Array, false, false)
 - #4 /home/daan/domains/../library/Zend/Locale/Data.php(307): Zend_Cache::factory('Core', 'File', Array, Array)
 - #5 /home/daan/domains/../library/Zend/Locale/Format.php(796): Zend_Locale_Data::getList('nl_NL', 'day')
 - #6 /home/daan/domains/../library/Zend/Locale/Format.php(1106): Zend_Locale_Format::_parseDate('16-02-2013', Array)
 - #7 /home/daan/domains/../library/Zend/Date.php(4763): Zend_Locale_Format::getDate('16-02-2013', Array)
 - #8 /home/daan/domains/../library/Zend/Validate/Date.php(175): Zend_Date::isDate('16-02-2013', 'MM-DD-YYYY', NULL)
 - #9 /home/daan/domains/../library/Zend/Form/Element.php(1391): Zend_Validate_Date->isValid('16-02-2013', Array)
 - #10 /home/daan/domains/../library/Zend/Form.php(2135): Zend_Form_Element->isValid('16-02-2013', Array)
 - #11/home/daan/domains/../application/controllers/BugController.php(27): Zend_Form->isValid(Array)
 - #12 /home/daan/domains/../library/Zend/Controller/Action.php(513): BugController->submitAction()
 - #13 /home/daan/domains/../library/Zend/Controller/Dispatcher/Standard.php(289): Zend_Controller_Action->dispatch('submitAction')
 - #14 /home/daan/domains/../library/Zend/Controller/Front.php(954): Zend_Controller_Dispatcher_Standard->dispatch(Object(Zend_Controller_Request_Http), Object(Zend_Controller_Response_Http))
 - #15 /home/daan/domains/../library/Zend/Application/Bootstrap/Bootstrap.php(97): Zend_Controller_Front->dispatch()
 - #16 /home/daan/domains/../library/Zend/Application.php(366): Zend_Application_Bootstrap_Bootstrap->run()
 - #17 /home/daan/domains/../public_html/index.php(26): Zend_Application->run()
 - #18 {main} 

Application.ini:

resources.cachemanager.configFiles.frontend.name = File
resources.cachemanager.configFiles.frontend.customFrontendNaming = false
resources.cachemanager.configFiles.frontend.options.lifetime = false
resources.cachemanager.configFiles.frontend.options.automatic_serialization = true    
resources.cachemanager.configFiles.backend.name = File
resources.cachemanager.configFiles.backend.customBackendNaming = false
resources.cachemanager.configFiles.backend.options.cache_dir = APPLICATION_PATH      "/../tmp"
resources.cachemanager.configFiles.frontendBackendAutoload = false

Initcache:

 protected function _initCaching() {
$frontend = array(
'lifetime' => $time,
'automatic_serialization' => true
);
$backend = array(
'cache_dir' => sys_get_temp_dir(),
);
$cache = Zend_Cache::factory('core', 'File', $frontend, $backend);
Zend_Registry::set('cache', $cache);

}

Folder Structure:
.htpasswd
application
awstats
library
logs
public_ftp
public_html
tmp

Upvotes: 3

Views: 19711

Answers (8)

Swapnil Waghmare
Swapnil Waghmare

Reputation: 21

One of the causes for this problem in CentOS/RedHat could be Selinux. I got rid of this issue by just disabling Selinux

Edit the /etc/selinux/config file and set the SELINUX to disabled.

Upvotes: 0

samsoft
samsoft

Reputation: 46

Change path in /install/config/, edit file vfs.php and put new path name.

Upvotes: 0

Deep
Deep

Reputation: 1

assign full path for your cache directory. For example,

'cache_dir' => '/var/www/html/var/cache1',

Upvotes: 0

Dharmendra Singh
Dharmendra Singh

Reputation: 11

magento root

Creating "tmp" file in the magento directory solved this error for me. I was able to access admin easily

Upvotes: 0

user3192707
user3192707

Reputation: 1

The answer of this question is that open File.php file and change the path of the tmp folder. This issue mostly comes when you tranfer your site from one server to another. When you transfer the site then the path of the tmp folder doesn't changed to the the new one. So edit the file.php and change the path of the tmp folder.

Upvotes: 0

Tim Fountain
Tim Fountain

Reputation: 33148

Remove the _initCaching function from your bootstrap, you shouldn't have this and the application.ini entries as they are both trying to setup the same thing (but using different cache locations).

Your cache dir is set to APPLICATION_PATH "/../tmp" - i.e. a folder called 'tmp' at the root of your application (NOT in the application folder). Are you 100% sure that your tmp folder exists at this location? If so, you could try changing the application.ini configuration to use a full path instead:

resources.cachemanager.configFiles.backend.options.cache_dir = "/home/daan/domains/whatever/tmp"

just to see if that fixes the problem.

If you still can't get it working please post more information about the file structure of your application.

Upvotes: 0

liyakat
liyakat

Reputation: 11853

cache_dir must be a directory :

This problem came generally when you move your code to another host or server . There are mainly two solution for this problem

1 - Make sure your cache directory is writable or you can make writable to var folder of magento

but sometimes this situation does not work so here is the alternate solution. Go to this location lib/Zend/Cache/Backend/ and open file.php file you’ll see the code something like this

protected $_options = array(
        'cache_dir' => null,
        'file_locking' => true,
        'read_control' => true,
        'read_control_type' => 'crc32',
        'hashed_directory_level' => 0,
        'hashed_directory_umask' => 0700,
        'file_name_prefix' => 'zend_cache',
        'cache_file_umask' => 0600,
        'metadatas_array_max_size' => 100
    );

change this code as below

protected $_options = array(
        'cache_dir' => '/var/www/html/webkul/magento/tmp',
        'file_locking' => true,
        'read_control' => true,
        'read_control_type' => 'crc32',
        'hashed_directory_level' => 0,
        'hashed_directory_umask' => 0700,
        'file_name_prefix' => 'zend_cache',
        'cache_file_umask' => 0600,
        'metadatas_array_max_size' => 100
    );

assign path of cache_dir as per your configuration .

Upvotes: 7

chandresh_cool
chandresh_cool

Reputation: 11830

May be Zend is not able to find your cache directory. Try to se this in Bootstrap.php like this

protected function _initCache() {
    $frontend = array(
        'lifetime' => $time,
        'automatic_serialization' => true
    );
    $backend = array(
        'cache_dir' => sys_get_temp_dir(), /**automatically detects**/
    );
    $cache = Zend_Cache::factory('core', 'File', $frontend, $backend);
    Zend_Registry::set('cache', $cache);
}

Upvotes: 0

Related Questions