After uninstalling all dependent sub-modules I finally wanted to uninstall commerce core module with the following response in drush:

exception 'Drupal\Core\Extension\ModuleUninstallValidatorException' with message 'The following reasons prevent the modules from being uninstalled: Fields pending deletion' in /var/www/drupal/web/core/lib/Drupal/Core/Extension/ModuleInstaller.php:354
Stack trace:
#0 /var/www/drupal/web/core/lib/Drupal/Core/ProxyClass/Extension/ModuleInstaller.php(91):
Drupal\Core\Extension\ModuleInstaller->uninstall(Array, true)
#1 /var/www/drupal/vendor/drush/drush/commands/core/drupal/environment.inc(227):
Drupal\Core\ProxyClass\Extension\ModuleInstaller->uninstall(Array)
#2 /var/www/drupal/vendor/drush/drush/commands/core/drupal/pm_8.inc(82): drush_module_uninstall(Array)
#3 /var/www/drupal/vendor/drush/drush/commands/pm/pm.drush.inc(1237): _drush_pm_uninstall(Array)
#4 [internal function]: drush_pm_uninstall('commerce')
#5 /var/www/drupal/vendor/drush/drush/includes/command.inc(422): call_user_func_array('drush_pm_uninst...', Array)
#6 /var/www/drupal/vendor/drush/drush/includes/command.inc(231): _drush_invoke_hooks(Array, Array)
#7 [internal function]: drush_command('commerce')
#8 /var/www/drupal/vendor/drush/drush/includes/command.inc(199): call_user_func_array('drush_command', Array)
#9 /var/www/drupal/vendor/drush/drush/lib/Drush/Boot/BaseBoot.php(67): drush_dispatch(Array)
#10 /var/www/drupal/vendor/drush/drush/includes/preflight.inc(66): Drush\Boot\BaseBoot->bootstrap_and_dispatch()
#11 /var/www/drupal/vendor/drush/drush/drush.php(12): drush_main()
#12 {main}

Comments

ñull created an issue. See original summary.

agoradesign’s picture

Sounds like you just have to run Cron (maybe a few times). It depends on how much data you've created that now must be deleted before Drupal can actually delete the fields and related configuration. This is not a Commerce issue

ñull’s picture

Yes, you are right that running Cron fixed the issue. For convenience sake, as a feature, it might be interesting to force this clean-up at uninstall.

bojanz’s picture

Category: Bug report » Support request

This is a Drush bug, where it allows uninstall to proceed even though there are fields pending deletion.
The UI (admin/modules) respects this and actually won't allow uninstall to proceed until you run Cron.
I suggest opening an issue in https://github.com/drush-ops/drush/issues

This whole run-cron thing is a core limitation that I'm unsure how to work around. We could try running the field deletion process after each Commerce submodule is uninstalled, it might help some sites (the ones that don't have a lot of content). But in general, uninstallation is a rare task that's even more rarely performed on production, so I'm not convinced it's worth it.

bojanz’s picture

Status: Active » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.