27 Jan.2021

Drupal 10: Resolved: The following reasons prevent the modules from being uninstalled: Fields pending deletion

drupal entities

When you try to uninstall a module that has a field that you have used, it can throw the following error:

The following reasons prevent the modules from being uninstalled: Fields pending deletion

In my case, it was when I tried to disable the "Comment" module. This is an issue that can happen in both Drupal 8 and Drupal 9. This is due to the fact, that Drupal doesn’t actually delete data for the field when you delete the field. It deletes the data during cron runs. If cron hasn’t been run enough times since you deleted the field, drupal won’t let you uninstall the module.

To force drupal to purge the data, you can run the following command

drush php-eval  'field_purge_batch(1000);'

You can also use an user interface provided by devel_php module.

Increase 1000 to a high enough number to wipe out the data, or run a few times. After this has completed, you should be able to uninstall the module.

References:
Module uninstall dependencies
The message "Required by Drupal (Fields Pending Deletion)"
Can’t uninstall YAML because of the following reason: Fields pending deletion

Ruslan Piskarov

Ukraine
PHP/WEB Developer / Drupal Expert. More than 11 years of experience delivering Drupal based General Purpose solutions for different sectors such as Job Boards, Product Portfolios, Geo Coding, Real Estate solutions, E-Commerce, Classifieds, Corporate and online Magazines/Newspapers.