Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"Could not determine temp directory, please specify a cache_dir manually"

Magento admin throws an exception:

Could not determine temp directory, please specify a cache_dir manually

It is fresh instalation on new hosting package.

like image 650
gSorry Avatar asked Dec 25 '13 13:12

gSorry


3 Answers

Usually it will happen in shared web hosting, but also some times on individual server, if the permission of tmp folder is set wrong.

Many people suggest to modify the file: /lib/Zend/Cache/Backend/File.php to fix this problem. However, it may be a trap when you upgrade your Magento, as this file resides as core file of Magento. I recommend to use Magento's override feature.

Firstly, copy /lib/Zend/Cache/Backend/File.php to /app/code/local/Zend/Cache/Backend/File.php.

Then on line 91 or near this line, you will find:

'cache_dir' => null,

Change to:

'cache_dir' => "var/tmp/",

You can change the cache folder wherever you want. Now create a directory named tmp(or whatever name you have given above) under var folder and change the permission to 777 if necessary.

like image 170
Mohit Kumar Arora Avatar answered Oct 27 '22 08:10

Mohit Kumar Arora


This is only the permission issue. Just set the 777 permission to the cache directory and you are all done. try it.

For more details you can follow the link.

When ever you set the permission be sure it is recurrsively set..

chmod 777 -R /var/cache

this is the function


    public function getTmpDir()
        {
            $tmpdir = array();
            foreach (array($_ENV, $_SERVER) as $tab) {
                foreach (array('TMPDIR', 'TEMP', 'TMP', 'windir', 'SystemRoot') as $key) {
                    if (isset($tab[$key])) {
                        if (($key == 'windir') or ($key == 'SystemRoot')) {
                            $dir = realpath($tab[$key] . '\\temp');
                        } else {
                            $dir = realpath($tab[$key]);
                        }
                        if ($this->_isGoodTmpDir($dir)) {
                            return $dir;
                        }
                    }
                }
            }
            $upload = ini_get('upload_tmp_dir');
            if ($upload) {
                $dir = realpath($upload);
                if ($this->_isGoodTmpDir($dir)) {
                    return $dir;
                }
            }
            if (function_exists('sys_get_temp_dir')) {
                $dir = sys_get_temp_dir();
                if ($this->_isGoodTmpDir($dir)) {
                    return $dir;
                }
            }
            // Attemp to detect by creating a temporary file
            $tempFile = tempnam(md5(uniqid(rand(), TRUE)), '');
            if ($tempFile) {
                $dir = realpath(dirname($tempFile));
                unlink($tempFile);
                if ($this->_isGoodTmpDir($dir)) {
                    return $dir;
                }
            }
            if ($this->_isGoodTmpDir('/tmp')) {
                return '/tmp';
            }
            if ($this->_isGoodTmpDir('\\temp')) {
                return '\\temp';
            }
            Zend_Cache::throwException('Could not determine temp directory, please specify a cache_dir manually');
        }

defined in file lib/Zend/Cache/Backend.php

http://www.webtechnologycodes.com/magento-error-could-not-determine-temp-directory-please-specify-a-cache_dir-manually/

like image 27
Vinay Sikarwar Avatar answered Oct 27 '22 09:10

Vinay Sikarwar


  1. Create tmp folder in root of your magento installation with 777 permissions.
  2. Open lib/Zend/Cache/Backend/File.php
  3. Find $_options property and change line: 'cache_dir' => null, to 'cache_dir' => 'tmp',
  4. Refresh page.
like image 23
gSorry Avatar answered Oct 27 '22 07:10

gSorry