I already read the multiple questions regarding symfony and permission issues.
My problem is this: When cache:clear creates the directory, apache can't access the cache. When apache creates the directory on page call, cache:clear can't access.
The fun thing is that it only occurs in one project (which I got from a customer). In all others it works from both sides. So something with the permissions seems to be wrong.
For a start, I delete all folders within app/cache.
Then I set a sudo chmod -R 777 app/cache
.
We should have a clean start now.
Test 1
Now I run app/dev cache:clear. Folders dev and prod will be created. I take a look at the permissions on the dev folder:
crismancich (me) - Custom
_www - Custom
crismancich (me) - Read & Write
wheel - Read only
everyone - Read only
As a result apache will not be able to write in the cache.
Test 2
Now I try the other direction. Again I delete the subfolders via sudo rm -r app/cache/*
and set a sudo chmod -R 777 app/cache
.
Then I just call the website via my browser. The dev directory is created. The permissions are as follows:
crismancich (me) - Custom
_www - Custom
_www - Read & Write
wheel - Read only
everyone - read only
Now apache can access the files. But when I use app/console cache:clear
, I get a...
`[RuntimeException] Publication
Unable to write in the cache directory (/Workspace/ACME_Compliance_Tool_HE
AD/ComplianceTool/app/cache/dev)
Additional Tests
When I go on from here andf fire the recursive chmod again, the app/console cache:clear
at least starts but bumps into an error deeper down...
[Symfony\Component\Filesystem\Exception\IOException]
Failed to remove file /Workspace/ACME_Compliance_Tool_HEAD/ComplianceTool/
app/cache/dev_old/profiler/81/27/ba2781
In fact there is no app/cache/dev_old
. I guess the cache:clear would first rename and then delete the directory. Looks like the renaming does not work and this error is not handled.
If I use sudo app/console cache:clear
, it will work, But then again apache can't access the files and will leave me with a blank page and the error:
PHP Fatal error: Uncaught exception 'RuntimeException' with message 'Failed to write cache file "/Workspace/ACME_Compliance_Tool_HEAD/ComplianceTool/app/cache/dev/classes.php".' in /Workspace/ACME_Compliance_Tool_HEAD/ComplianceTool/vendor/symfony/symfony/src/Symfony/Component/ClassLoader/ClassCollectionLoader.php:205
Using the file info dialog in finder and granting Read & Write for _www for cache or dev and all subfolders or the whole folder structure from "/Workspace/ACME_Compliance_Tool_HEAD" has no effect at all.
A sudo chmod -R 777 app/cache
lets apache create cache files again, but then again, cache:clear can't delete the files created by apache.
Result I end up chmodding each time I have to use console commands that create/change/delete files. By the time that's very annoying.
My question Why does it work with different projects? Where is the problem?