Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] symfony console cache:clear write folder with 775 rights #1968

Closed
thibaut-st opened this issue Dec 8, 2017 · 19 comments
Closed

[BUG] symfony console cache:clear write folder with 775 rights #1968

thibaut-st opened this issue Dec 8, 2017 · 19 comments

Comments

@thibaut-st
Copy link

Hi,

When I run the php bin/console cache:clear command, the easyadmin cache folder under var/cache/dev/easyadmin is created with 775 rights instead of 777.
So When I go on the web page I get:
The directory "my_path_to/var/cache/dev/easy_admin" is not writable.
As if the umask(0000); from the console didn't work?

I tracked the issue to the CacheManager class, calling the parent::construct of FilesystemCache with no $umask third parameter. That third parameter is 0002 by default in the FilesystemCache construct.

But I think if it was really an issue with the bundle, someone else would have reported it by now. Maybe I lack some conf?

@thibaut-st
Copy link
Author

P.S. I hacked it temporarily with that:
public function __construct($cacheDir) { if (($_SERVER['APP_ENV'] ?? 'dev')==='dev') { parent::__construct($cacheDir, self::EXTENSION,0000); }else{ parent::__construct($cacheDir); } }

@javiereguiluz
Copy link
Collaborator

Not sure what to say ... I haven't experience this error ever and I don't remember any reported issue about this. But it looks important enough to keep investigating it.

@thibaut-st
Copy link
Author

thibaut-st commented Dec 17, 2017

My configuration:

  • VirtualBox on Windows 10
  • ElementaryOs on VirtualBox
  • Apache: Server version: Apache/2.4.29 (Ubuntu) - Server built: 2017-12-13T08:13:20
  • PHP: PHP 7.2.0-2+ubuntu16.04.1+deb.sury.org+2 (cli) (built: Dec 7 2017 20:14:31) ( NTS )

What are other useful informations I could provide?

Some screenshoot:

capture d ecran du 2017-12-17 14 14 04
capture d ecran du 2017-12-17 14 11 56

EDIT:
I tested on Windows and no problems (as to be expected with Windows right management)

@Rzial
Copy link

Rzial commented Dec 19, 2017

Having same issue here

  • VMware Workstation on Windows 10
  • Debian 9 on VMware Workstation
  • Nginx: Server version: 1.12.2-1~stretch
  • PHP-FPM: 7.2.0-1+0~ 20171201111333.14+stretch~1.gbp47ee8a

@lambertbeekhuis
Copy link

Having the same issue, php7.1 on mac locally, apache installed. Solve it with a 'sudo chmod -R 777 var/cache/' after each cache:clear, but annoying

@blackbart420
Copy link

Same problem on archlinux, I have to do sudo chmod -R 777 var/cache/' after each cache:clear .....

@thibaut-st
Copy link
Author

Any news about this issue?

@blackbart420
Copy link

I ran composer update but I still have the issue

@javiereguiluz
Copy link
Collaborator

javiereguiluz commented Jan 17, 2018

I submitted a pull request to fix this (#1965) but nobody has reviewed or tested or commented on it yet.

Update: sorry, I linked to the wrong pull request.

@javiereguiluz
Copy link
Collaborator

Some of you showed that running a chmod -R 777 var/cache/ solved the problem ... but we'd need to know the cause of this problem. I don't suffer this issue so for me it's hard to debug. I'd need your help. Thanks.

@thibaut-st
Copy link
Author

What informations would be useful?
I just installed it from composer, add my entity to the config file, and that's it.

@Gwynei
Copy link

Gwynei commented Jan 29, 2018

Having the issue as well.

Thing I notice is that the easy_admin folder is the ONLY folder without a write permission for everyone. See screenshot below. This is the result just after a cache:clear --env=dev command.

Specs:
Ubuntu 16.04.3 LTS
setfacl commands executed as documented
easy_admin installed using flex

image

If you need more info let me know.

@raress96
Copy link
Contributor

raress96 commented Feb 9, 2018

I also have the same problem, on both Linux and Windows.

@javiereguiluz
Copy link
Collaborator

I'm closing this issue because we're starting a new phase in the history of this bundle (see #2059). We've moved it into a new GitHub organization and we need to start from scratch: no past issues, no pending pull requests, etc.

I understand if you are angry or disappointed by this, but we really need to "reset" everything in order to reignite the development of this bundle.

@ebuildy
Copy link

ebuildy commented Mar 17, 2018

From Symfony 4, all plugins/bundles should rely on cache warmup to write on cache (see https://symfony.com/doc/current/setup/file_permissions.html).

@tgalopin
Copy link

Hey @javiereguiluz !

I have the same problem and I'm pretty sure it comes from virtualized environments (or similar environments) as the user of the webserver does not have the permissions to write the cache cleared by the console/user manually.

However as @ebuildy said, we should rely on Symfony caching features handling this for us. Let's discuss this :) (here or on Slack if you want).

@javiereguiluz
Copy link
Collaborator

I don't use virtualized/containarized apps, so I'm afraid I can't fix this myself. If anyone with experience knows how to solve this, please send a pull request and I'll help reviewing it, testing it (in non-virtualized apps), etc. Thanks a lot!!

@tgalopin
Copy link

I'll have a look :) .

javiereguiluz added a commit that referenced this issue Jun 10, 2018
…vironment (nielsvandermolen)

This PR was squashed before being merged into the 1.x branch (closes #2234).

Discussion
----------

Fix #1968 [Bug] Add workaround for cache permissions dev environment

Applied the workaround in #1968 comment 2. It seems to be important to get this in because the steps are communicated in the [quick demo blog article from Fabian](http://fabien.potencier.org/symfony4-demo.html)

Many people can reproduce the issue with the following steps:

1. Install latest stable Symfony 4 version
2. Install this bundle with the admin package (composer req admin)
3. Creating a product and update doctrine
4. Go to the website and you should see the error:
5. The directory "/var/www/project/var/cache/dev/easy_admin" is not writable.
6. Temporary solve it by chmod 777 var/cache/dev/easy_admin
7. Cache clear the error appears again (permission of the folder is set to 775

With the patch the issue does not occur and the permissions of the directory is set to 777. It seems the patch is only needed for the development environment because in the production environment the cache is build before pages are visited (warmup).

Commits
-------

f73a6e4 Fix #1968 [Bug] Add workaround for cache permissions dev environment
javiereguiluz added a commit that referenced this issue Jun 10, 2018
* 1.x:
  Fixed code syntax
  Fix #1968 [Bug] Add workaround for cache permissions dev environment
  save a lot of template exists checks
@danielszwarc
Copy link

IMHO this fix will work only if you explicit set APP_ENV variable to 'dev' (so Symfony environment is 'dev').
But by default in Symfony if APP_ENV is missing then Symfony environment is also 'dev' - fix is not working in this situation.
According to https://symfony.com/doc/current/setup/file_permissions.html Symfony use umask(0000), so fix should be like this:
if (!umask()) { parent::__construct($cacheDir, self::EXTENSION, 0000); } else { parent::__construct($cacheDir); }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

10 participants