1

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?

miltone
  • 4,416
  • 11
  • 42
  • 76
  • 1
    It's normal, when you create file, file belong to you right? Read how to setup permissions: http://symfony.com/doc/current/book/installation.html#book-installation-permissions – malcolm Jan 10 '16 at 20:12
  • Hi Malcolm and thanks for the reply. I should have mentioned I followed this article carefully and tried out every single option. – Boris Crismancich Jan 10 '16 at 20:43

1 Answers1

1

I did not find the reason, but I found a solution:

I zipped the files and unzipped them to a new directory. That way I seem to have gotten rid of the permission problem whatever it was.

  • 1
    Interestingly it works only when it is unzipped to a new unused directory. When I delete the old one, unzip it to the same location, I seem to 'inherit' the same problem again. I guess not from the parent directory, als this is /Workspace in my case and other projects in Workspace never had the issue. Just this project I got from a customer. – Boris Crismancich Jan 10 '16 at 20:52
  • That is somehow brilliant :) – Sliq Jul 09 '19 at 14:32