Warnings thrown for mkdir despite folder existing

Created on 3 September 2024, 2 months ago
Updated 19 September 2024, about 2 months ago

Problem/Motivation

I have a D10.3.2 site throwing warnings on the home page:

    User warning: mkdir(): Permission Denied in Drupal\Component\PhpStorage\FileStorage->createDirectory() (line 125 of core/lib/Drupal/Component/PhpStorage/FileStorage.php).

Some debugging revealed that it happens when attempting to create the php/twig folder in sites/default/files...which already exists. Opening one of the warning messages displays these lines at the start:

    Drupal\Component\PhpStorage\FileStorage->createDirectory('sites/default/files/php', 511) (Line: 103)
    Drupal\Component\PhpStorage\FileStorage->createDirectory('sites/default/files/php/twig', 511) (Line: 73)
    Drupal\Component\PhpStorage\FileStorage->ensureDirectory('sites/default/files/php/twig') (Line: 66)
    Drupal\Component\PhpStorage\MTimeProtectedFastFileStorage->save('66d715fbbd5fb_views-view.html.twig_p16UMguTdIA_XNOtJzgOUxTOu', '<?php

The site settings are to not display warnings. The markup providing these messages is being dynamically inserted by core. I've also tried the disable_messages module.

Not sure why it feels that not being able to create a directory that already exists is an issue, if that's what's happening, but regardless, how do I address this?

The permissions currently (in an attempt to get by these warnings) are:
default/files: 777
default/files/php: 775
default/files/php/twig: 775

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

Introduced terminology

API changes

Data model changes

Release notes snippet

💬 Support request
Status

Closed: outdated

Version

10.3

Component
File system 

Last updated 2 days ago

Created by

🇺🇸United States j. ayen green

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @j. ayen green
  • You should take that error at face value, because it is a low-level PHP error. Is the web server process user allowed to create directories there?

  • 🇺🇸United States j. ayen green

    I have been, but even setting all folders from files on down to 777 just to test it had no effect. As for the web server process user, this is on ddev, and all the ddev environments (of which this is the only one with the issue) are the same user/group. Could this be an nginx setting, or something to do with .htaccess?

  • Unless ddev is actually running as a user that maps to a host user, which is unlikely, I think default/files/php needs to be 777 also.

  • 🇺🇸United States j. ayen green

    Yes, what I meant was I've tried chmod -R 777 sites/default/files, which made php and php/twig 777, and no joy.

  • As I said I think default/files/php needs to be 777 also. I could be wrong but AFAICS you did not try that.

  • 🇺🇸United States j. ayen green

    That command made
    sites/default/files
    sites/default/files/php
    sites/default/files/php/twig
    and all the files in them 777

  • What command? Did I suggest a command?

    FYI the default files permissions in a DDEV install are as follows:

    ls -al sites/default/files
    total 8
    drwxr-xr-x  8 user1  staff  256 Sep  3 13:28 .
    drwxr-xr-x  8 user1  staff  256 Sep  3 13:26 ..
    -r--r--r--  1 user1  staff  486 Sep  3 13:27 .htaccess
    drwxrwxr-x  8 user1  staff  256 Sep  3 13:28 css
    drwxrwxr-x  6 user1  staff  192 Sep  3 13:28 js
    drwxrwxrwx  3 user1  staff   96 Sep  3 13:27 php
    drwxrwxr-x  2 user1  staff   64 Sep  3 13:27 styles
    drwxr-xr-x  3 user1  staff   96 Sep  3 13:27 sync
    

    If yours are different, and you are still struggling with this I suggest instead the #support channel in Drupal Slack because I don't feel these comments are helping you.

  • 🇺🇸United States j. ayen green

    No, you didn't, I did :-) I just went back (a couple messages up) and formatted it as code.
    Ok, I do appreciate your spending the time. This issue seems to be on the cusp of Linux and Drupal...not sure where it will fall. I'll head over to Slack with a pitstop first at ddev.

  • One other issue could be sluggish syncing between the host and the container. If the host isn't Linux, and it's, for example, Mac OS, be sure that mutagen is running.

  • 🇺🇸United States j. ayen green

    So it was weirder weirdness than I thought. It was some docker container glitch. rfay had me clean up docker, power off ddev, turn off mutagen, start it up (messages were gone), power off again, turn on mutagen and start it up, and the messages are still gone.

    For anyone who might have the same issue, these were the commands:

    ddev poweroff
    docker rm -f $(docker ps -aq)
    ddev mutagen reset 
    ddev config global --performance-mode=none 
    ddev start

    see if the messages are gone

    ddev poweroff && ddev config global --performance-mode=mutagen && ddev start
    
  • Status changed to Closed: outdated 2 months ago
  • First commit to issue fork.
  • 🇮🇳India KumudB Ahmedabad

    Resolution: Issue Not Reproducible in Drupal 10.2.3

    After further testing, I was unable to reproduce this issue on a site running Drupal version 10.2.3. The warnings related to the mkdir(): Permission Denied error when attempting to create the php/twig folder in sites/default/files are not occurring in this version.

    Given that the issue does not persist in 10.2.3, I am marking this issue as resolved and closing it.

Production build 0.71.5 2024