Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Symfony Warning : rename (../app/cache/dev , ../app/cache/dev_old ) : Access Denied . (Code : 5)

Tags:

symfony

I am working on Symfony project.

When i try to do :

php app/console cache:clear

i get the following ErrorException:

Warning : rename (../app/cache/dev , ../app/cache/dev_old ) : Access Denied . (Code : 5) in ../vendors/Symfony/src/Symfony/Bundle/FrameworkBundle/Command/CacheClearCommand.php on line 76

What is the problem here? I have given all permissions to the user on my machine (Windows 7 OS). Any ideas why it is happening?

Thank You.

like image 784
VishwaKumar Avatar asked Jan 30 '12 10:01

VishwaKumar


5 Answers

I had the same issue with Symfony 4.1.13 and the root cause was that the VS Code was using the file "var/cache/dev/srcDevDebugProjectContainer.xml4QSKuA".

The issue was Cannot rename "var/cache/dev/srcDevDebugProjectContainer.xml4QSKuA".

I fix it adding **/var on the fields "Files to Exclude"

See the following steps:

1º Step:

Firs Step

2º Step search for "exclude" word, then add **/var/cache as the following image:

Second Step

It's worked for me.

like image 80
Caique Andrade Avatar answered Oct 28 '22 12:10

Caique Andrade


If you're using text editors as Sublime Text try to ignore path of cached files

Go to Preferences/Setting

edit config file

{
...
     "folder_exclude_patterns": ["var","node_modules",  ".git"],
...
}

in my case

Cache folders containers.

Symfony 4

/var

Symfony 2

/app/cache

Nice coding!

like image 20
skyllet Avatar answered Oct 28 '22 10:10

skyllet


Be sure that the files are not in use (as meze pointed out). If you're using something like TortoiseGit or Netbeans, etc - be sure to mark the cache folder as ignored so that they are not accessed.

If all else fails, download a free program like Unlocker that will allow you to quickly and easily detach running processes from the files/folders you are trying to modify.

like image 27
leek Avatar answered Oct 28 '22 12:10

leek


To expand on leek's post, Symfony 2 cache-clearing operations shuffle the cached items across different folders during the cleanup. Part of this process includes creating cache/dev-new/ and cache/dev-old/ folders.

If you are using Eclipse or another IDE that dynamically monitors subfolders within your project, the IDE will nearly instantly spot the new folder creation and look in those folders for new files (in Eclipse, I noticed the DLTK module constantly doing this in the Progress View). This may unfortunately get in the way of Symfony, which wants to rename and/or delete these folders.

Specifically with Eclipse Indigo on Windows 7 64-bit, you can remove the cache/, cache/dev/, cache/dev_old/ and cache/dev_new/ folders from the build path by right-clicking your project and selecting "Build Path > Configure Build Path...". This originally had no effect for me; I kept seeing the DLTK module trying to index the cache folders. I ended up uninstalling the Aptana Studio plug-in, closing all Editor documents, shutting down Eclipse, manually deleting the sub-folders in the cache/ folder, running Symfony cache:clear, then starting up Eclipse and reinstalling Aptana. Seems to have worked thus far.

like image 39
Blake B. Avatar answered Oct 28 '22 11:10

Blake B.


It's an issue with Symfony 2.0.x and Symfony 2.1.x. These a workaround for this:

Open the file: src\Symfony\Bundle\FrameworkBundle\Command\CacheClearCommand.php

and add the statement sleep(1); where the directory creation is failing, in the execute() function:

    //...
    rename($realCacheDir, $oldCacheDir);
    sleep(1);
    rename($warmupDir, $realCacheDir);
    //...

You might have to re-open the CLI twice and run cache:clear, but it will fix the problem after that

like image 42
qais Avatar answered Oct 28 '22 11:10

qais