"In FIlesystem.php like 302: Could not delete /web/sites/default/default.services.yml"
Introduction
During process of upgrading Drupal via Composer (some times composer require
) that involves a few straightforward steps to ensure site stays up-to-date, possible outcome can end up with an error, like this one "In FIlesystem.php like 302: Could not delete /web/sites/default/default.services.yml"
Environment:
Operation system: Ubuntu;
Web Server: Apache2;
Drupal: 10
Reason of the error
This error caused by strict file permissions of the parent folder in Drupal configuration directory.
(/web/sites/default/default.services.yml)drwxr-xr-x 3 ubuntu ubuntu 4096 Oct 30 11:18 default
as on this case - folder "default" has strict write permissions. (no write)
How to fix
To fix, we need to use chmod command and change folder permission chmod
# Alternative approach
chmod ug+w /web/sites/default
Using chmod command - add permission for write to folder "default"
Conclusion
Steps described in this tutorial are enough to fix "In FIlesystem.php like 302: Could not delete" error, after, process of upgrading Drupal via Composer will be completed without similar issues.
Important to keep correct file system permissions of Drupal folders and files as it can affect security and heath of Drupal site.
Warning
Drupal is known for strict security rules, this hardened folder permissions can be set back again automatically soon by Cron iteration.
Not recommended
It's possible to set Drupal not to do permissions hardening by adding such setting in settings.php
file$settings['skip_permissions_hardening'] = TRUE;