On Drupal 8, 9, or even Drupal 10, you might encounter any of the following error messages when running Drush or Composer commands in the command line. For instance, any of these errors can happen while installing a new module via composer, or running drush updb, or any CLI commands:
Installation failed, reverting ./composer.json and ./composer.lock to their original content.
and related, similar errors like:
[RuntimeException] Could not delete /sites/default/default.settings.php:
[RuntimeException] Could not delete /sites/default/default.services.yml:
It may be for the /web directory or /public_html directories depending on your webhosting setup or how Drupal had been installed in your server directories.
On Drupal 10, the similar error could be like below, and could happen when updating D10 core via composer / SSH:
In Filesystem.php line 288: Could not delete /public_html/web/sites/default/default.settings.php:
Drupal errors explained
Installation failed, reverting ./composer.json and ./composer.lock to their original content.
In Drupal, the error “Installation failed, reverting ./composer.json and ./composer.lock to their original content” indicates that Composer, the package manager used by Drupal, was unable to successfully install dependencies due to a conflict or issue with the versions specified in your composer.json file, causing it to revert back to the previous state of your project files.
[RuntimeException] Could not delete /sites/default/default.settings.php:
[RuntimeException] Could not delete /sites/default/default.services.yml:
Could not delete /public_html/web/sites/default/default.settings.php:
These errors in Drupal usually happens due to permission issues on the default.settings.php file. This file is set up by default to prevent accidental modifications or deletions, but sometimes it can cause problems during installations, updates, or migrations.
How to fix these Drupal errors:
There are two options generally provided:.
1. Change acceptable permissions of the /default directory to your user (add web or public_html if you are running the command from your root directory level)
chmod u+w sites/default
This will also fix errors when deleting for instance below Drupal system files, for instance, when you need to clean-up a the public_html, web, or home directory:
rm: cannot remove 'sites/default/default.services.yml': Permission denied
rm: cannot remove 'sites/default/settings.php': Permission denied
rm: cannot remove 'sites/default/files': Permission denied
Further, this also fixes issues when trying to edit and save Drupal’s settings.php using the File Manager broswer inter face:
The system failed to create the file “.../sites/default/settings.php.lock” (as EUID: 5469, EGID: 5382 5382) because of the following error: Permission denied
2. While recommended only for local development, and not on production, you may also include in your settings.php file the line below. If this is the only option that works, revert or remove the line again from production after the issue is resolved.
$settings['skip_permissions_hardening'] = TRUE;
![[SOLVED] Installation failed, reverting ./composer.json and ./composer.lock to their original content. [RuntimeException] Could not delete /sites/default/default.settings.php or default.services.yml 3 cpanel-error-settings.php](https://knowledgebase.ibuild.ph/wp-content/uploads/cpanel-error-settings.php_.jpg)