Unit tests: Exception : Error writing server configuration file ".htaccess"


Silverstripe Version: 4.3.3



If I run unit tests, I will get the following error messages:

Exception : Error writing server configuration file “.htaccess”


PHP Warning: file_put_contents(/var/www/html/myproject/public/assets/.htaccess): failed to open stream: Permission denied in /var/www/html/myproject/vendor/league/flysystem/src/Adapter/Local.php on line 136

I can fix it temporarily if I run chmod 777 /var/www/html/myproject/public/assets/ -R in terminal, but the problem recurs every time I run /dev/build?flush=all. How can I fix this permanently?

(I don’t even understand why running unit tests would need to write anything to .htaccess but I guess there is some logical reason.)

Thank you for your support :).


It’s most likely an ownership issue. The dev/build writes the htaccess and sets the permissions for itself. If you run everything as the web user, then it shouldn’t be an issue.