I downloaded and installed a new Drupal 8 site via Composer.
I generated a new module using Drupal Console.
I tried running a phpUnit functional test of the newly generated module, and it keeps failing due to some folder permission:

Exception: Warning: chmod(): Operation not permitted Drupal\Component\PhpStorage\FileStorage->createDirectory()() (Line: 168)

What grind my gears is that it was working OK a few days ago. Something is clearly wrong with my system, I just don't know what that is, or what changed since then.

I'm running a WSL with Apache 2.4.37 (PHP Version 7.2.12-1+ubuntu18.04.1+deb.sury.org+1).

I have all the detailed steps to reproduce the case, my full phpinfo, and some more relevant information in this gist I created.

I spent the last few days browsing for a known solution, and some cases appear to be similar, but none of them seems to hit the spot.

I am using Windows 10.0.17134.407; the tests from the browser are passing. All the files and folders on the project are owned by 'zoio' (user and group); the file permissions for folders and files in modules, sites/default/files, and sites/simpletest are set to 0777.

I tried to follow the tips on this WSL issue, but I just ended up with a different failure, still related to permission and ownership.

Exception: User warning: mkdir(): Permission Denied
Drupal\Component\PhpStorage\FileStorage->createDirectory()() (Line: 174)
/mnt/c/www/temp/d8_temp/web/core/lib/Drupal/Core/Test/HttpClientMiddleware/TestHttpClientMiddleware.php:51 (...) /mnt/c/www/temp/d8_temp/web/modules/custom/sandbox/tests/src/Functional/LoadTest.php:33
Tests: 1, Assertions: 1, Errors: 1.

  • Hey Zoio, this sounds very similar to github.com/Microsoft/WSL/issues/3172, is that one of the cases you came across? Did you run any Windows updates before the problem appeared? Nov 30, 2018 at 21:02
  • I haven't come across this one, but I tried it now. Still no success. No Windows Update runned recently. I also updated the post with more info based on your tips. Thanks, anyway.
    – Zoio Silva
    Dec 1, 2018 at 22:54
  • Ur welcome. Did you try running the tests from the browser? Dec 1, 2018 at 23:49
  • The tests from the browser are passing, though. This is very intriguing.
    – Zoio Silva
    Dec 2, 2018 at 4:27

3 Answers 3


The thing is, the chmod wasn't really working.

It was an issue with the mounted drivers in the WSL Ubuntu installation. Based on Stefanos Petrakis' comment, simply trying to unmount and mount the driver with the proper options enabled wouldn't solve the issue by itself. What solved was a bit more drastic:

  1. Factory reset the ubuntu (how-to);
  2. re-mount the driver, with the metadata option included (source):

    sudo umount /mnt/c
    sudo mount -t drvfs C: /mnt/c -o metadata,uid=1000,gid=1000

  3. Install php, Apache, and everything.

Only then, the phpunit tests did work properly.


It seems like the user zoio (the user you're running vendor/bin/phpunit as) doesn't have write permissions on your module folder.

Can you tell your module folder's owner and group?

If zoio isn't the owner and neither of its groups are assigned to this folder, then your script really won't be able to chmod it or modify its contents.

You need to grant write permissions to either the owner or the group.

As a quick and dirty test, you can try running chmod -R 777 path_to_your_module_folder.

Just remember to adjust folder permissions back once you've figured out the problem.

Let me know if this helps.

  • I updated the post with more info related to your answer. All project's folders and files are owned by zoio:zoio (user and group). Still, I runned the chmod recursively as you recommended, just to be sure. Still no success.
    – Zoio Silva
    Dec 1, 2018 at 22:57

One way to make this run would be by using sudo and the same user as the one running apache (that would be www-data according to your gist):

sudo -u www-data vendor/bin/phpunit -c ./web/core/ \

Good luck!

P.S.: (inspired from https://serverfault.com/a/453823)

  • I just tried it. Still no success: chmod(): Operation not permitted.
    – Zoio Silva
    Dec 4, 2018 at 15:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.