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

Unable to write in the "cache" directory #5520

Open
fculpo opened this issue Jan 2, 2022 · 9 comments
Open

Unable to write in the "cache" directory #5520

fculpo opened this issue Jan 2, 2022 · 9 comments

Comments

@fculpo
Copy link

fculpo commented Jan 2, 2022

On a fresh instance of self hosted wallabag, I get this error related to cache directory

2022/01/01 19:20:46 [error] 262#262: *1 FastCGI sent in stderr: "PHP message: PHP Fatal error:  Uncaught RuntimeException: Unable to write in the "cache" directory (/var/www/wallabag/var/cache/prod). in /var/www/wallabag/vendor/symfony/symfony/src/Symfony/Component/HttpKernel 

Stack trace: 
#0 /var/www/wallabag/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/Kernel.php(642): Symfony\Component\HttpKernel\Kernel->buildContainer()
#1 /var/www/wallabag/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/Kernel.php(135): Symfony\Component\HttpKernel\Kernel->initializeContainer()                                                                                                                             
#2 /var/www/wallabag/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/Kernel.php(195): Symfony\Component\HttpKernel\Kernel->boot()                                                                                                                                          
#3 /var/www/wallabag/web/app.php(13): Symfony\Component\HttpKernel\Kernel->handle(Object(Symfony\Component\HttpFoundation\Request)) 
@fculpo
Copy link
Author

fculpo commented Jan 2, 2022

I'm simply using docker image wallabag/wallabag

@j0k3r
Copy link
Member

j0k3r commented Jan 6, 2022

Without much more code or snippet of what you've done, we can't help you.

@yitsushi
Copy link

yitsushi commented Feb 15, 2022

I had the same error here using wallabag/wallabag:2.4.3, details may help.

Docker compose file (docker stack deploy):

---
version: '3.2'

services:
  web:
    image: wallabag/wallabag:2.4.3
    networks:
      - traefik-public
    ports:
      - 80
    environment:
      - POSTGRES_PASSWORD="xxx"
      - POSTGRES_USER="wallabag"
      - SYMFONY__ENV__DATABASE_DRIVER="pdo_pgsql"
      - SYMFONY__ENV__DATABASE_HOST="xxx"
      - SYMFONY__ENV__DATABASE_PORT=5432
      - SYMFONY__ENV__DATABASE_NAME="wallabag"
      - SYMFONY__ENV__DATABASE_USER="wallabag"
      - SYMFONY__ENV__REDIS_PASSWORD="xxx"
      - SYMFONY__ENV__SECRET="xxx"
      - SYMFONY__ENV__MAILER_HOST="xxx"
      - SYMFONY__ENV__MAILER_USER="xxx"
      - SYMFONY__ENV__MAILER_PASSWORD="xxx"
      - SYMFONY__ENV__FROM_EMAIL="xxx"
      - SYMFONY__ENV__TWOFACTOR_AUTH=true
      - SYMFONY__ENV__TWOFACTOR_SENDER="xxx"
      - SYMFONY__ENV__FOSUSER_REGISTRATION=false
      - SYMFONY__ENV__FOSUSER_CONFIRMATION=false
      - SYMFONY__ENV__DOMAIN_NAME="xxx"
      - SYMFONY__ENV__SERVER_NAME="xxx"
      - SYMFONY__ENV__REDIS_HOST="xxx"
      - SYMFONY__ENV__REDIS_PORT=6379
      - SYMFONY__ENV__DATABASE_PASSWORD="xxx"
    deploy:
      labels:
        - "traefik.enable=true"
        - "traefik.http.routers.wallabag-router.rule=Host(`xxx`)"
        - "traefik.http.services.wallabag-service.loadbalancer.server.port=80"
        - "traefik.http.routers.wallabag-router.tls=true"
        - "traefik.http.routers.wallabag-router.tls.certresolver=cloudflare"
        - "traefik.docker.network=traefik-public"

networks:
  traefik-public:
    external: true

Error Message:

2022/02/15 09:56:13 [error] 217#217: *4 FastCGI sent in stderr: "PHP message: PHP Fatal error:  Uncaught RuntimeException: Unable to write in the "cache" directory (/var/www/wallabag/var/cache/prod). in /var/www/wallabag/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/Kernel.php:768
Stack trace:
#0 /var/www/wallabag/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/Kernel.php(642): Symfony\Component\HttpKernel\Kernel->buildContainer()
#1 /var/www/wallabag/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/Kernel.php(135): Symfony\Component\HttpKernel\Kernel->initializeContainer()
#2 /var/www/wallabag/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/Kernel.php(195): Symfony\Component\HttpKernel\Kernel->boot()
#3 /var/www/wallabag/web/app.php(13): Symfony\Component\HttpKernel\Kernel->handle(Object(Symfony\Component\HttpFoundation\Request))
#4 {main}
  thrown in /var/www/wallabag/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/Kernel.php on line 768" while reading response header from upstream, client: 10.0.4.7, server: _, request: "GET / HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "xxx"

Directory permissions:

$ docker exec -it wallabag_web.1.9xe38yco9fs9yfwwj7tlxuca8 /bin/ash
/ # ls -la /var/www/wallabag/var/
total 108
drwxr-xr-x    1 nobody   nobody        4096 Feb 15 09:53 .
drwxr-xr-x    1 nobody   nobody        4096 Feb 14 18:56 ..
-rw-r--r--    1 nobody   nobody       33831 Feb 14 18:57 SymfonyRequirements.php
-rw-r--r--    1 root     root         42982 Feb 15 09:53 bootstrap.php.cache
drwxr-xr-x    3 root     root          4096 Feb 15 09:53 cache
drwxr-xr-x    1 nobody   nobody        4096 Feb 14 18:56 logs
drwxr-xr-x    1 nobody   nobody        4096 Feb 14 18:56 sessions
/ # ls -la /var/www/wallabag/var/cache/
total 16
drwxr-xr-x    3 root     root          4096 Feb 15 09:53 .
drwxr-xr-x    1 nobody   nobody        4096 Feb 15 09:53 ..
drwxr-xr-x    2 root     root          4096 Feb 15 09:53 prod
/ # ls -la /var/www/wallabag/var/cache/prod/
total 8
drwxr-xr-x    2 root     root          4096 Feb 15 09:53 .
drwxr-xr-x    3 root     root          4096 Feb 15 09:53 ..

After container restart it had the right permission (don't ask how, i just restarted the container):

$ docker exec -it wallabag_web.1.z6dhju6mh363qzlaw0gwel8au /bin/ash
/ # ls -la /var/www/wallabag/var/
total 108
drwxr-xr-x    1 nobody   nobody        4096 Feb 15 10:05 .
drwxr-xr-x    1 nobody   nobody        4096 Feb 14 18:56 ..
-rw-r--r--    1 nobody   nobody       33831 Feb 15 10:06 SymfonyRequirements.php
-rw-r--r--    1 nobody   nobody       42982 Feb 15 10:05 bootstrap.php.cache
drwxr-xr-x    3 nobody   nobody        4096 Feb 15 10:06 cache
drwxr-xr-x    1 nobody   nobody        4096 Feb 15 10:06 logs
drwxr-xr-x    1 nobody   nobody        4096 Feb 15 10:06 sessions

@MarcelRobitaille
Copy link

MarcelRobitaille commented Feb 23, 2022

I am also getting this. I am using the docker-compose.yml from wallabag/docker. Interestingly, I was not getting any issues until I changed

- SYMFONY__ENV__MAILER_HOST=127.0.0.1
- SYMFONY__ENV__MAILER_USER=~
- SYMFONY__ENV__MAILER_PASSWORD=~

from their defaults.

EDIT: I can confirm that resetting these to their default values has resolved the issue (I say resolved, but I can't sign in because I'm not getting any confirmation email...).

EDIT 2: I added back these three variables one at a time, and everything is working now. I did change my email account password to remove troublesome special characters.

@nicosomb
Copy link
Member

@Kdecherf any idea?

@Kdecherf
Copy link
Member

@fculpo @yitsushi How did you run wallabag:install? It looks like you ran it as root within the container which breaks the execution.

You should be able to fix this by running docker exec -it --entrypoint sh wallabag_container "-c 'chown -R nobody: /var/www/wallabag'"

@yitsushi
Copy link

I just started a container from a compose file. Killing the container with docker rm (hard restart container) fixed it. Tried to reproduce but I couldn't. Can it be some strange race condition with how docker initializes things and the entry stript?

@Kdecherf
Copy link
Member

Maybe, I must admit that I'm using a different approach for my personal docker container, I made a draft here: wallabag/docker#256

@weilhr
Copy link

weilhr commented Oct 24, 2022

even though the issue is quite old, I try my luck and adding my comment by hoping this thread is still monitored.

I'm running wallabag since quite a while as docker instaces by using docker-compose as mentioned in wallabag docker install section. I'm not 100% from which version I came from - the old image says 2.4.3 and 2.5.1 but with different id than on hub.docker.com. Howeve I'm hitting exact the same issue. Unable to write to cache and sessions directories. After I've added the directories and run a cache:clear i got the login page back

in Docker conatiner "wallabag"
mkdir /var/www/wallabag/var/cache/prod/twig/ /var/www/wallabag/var/sessions/prod
chown nobody:nobody /var/www/wallabag/var/cache/prod/twig/ /var/www/wallabag/var/sessions/prod
/var/www/wallabag/bin/console cache:clear --env=prod --no-interaction

However my previous credentials are not recognized. Before doing any destructive testings, I though to bring up a fresh instance with same docker-compose but different data directories. On the fresh instance I was able to login with default credentials wallabag/wallabag after addid the directories. In any case I think the docker container is missing the directories and RUN commands to create and chown the directory should be added.

Will test later if I can login into my updated instance after I change back the SYMFONY__ENV__MAILER_* settings to default as mentioned earlier in this thread (#5520 (comment))

Thanks,
Robert

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

7 participants