Drupal8 - How to delete active configuration of a module

Drupal8 - How to delete active configuration of a module

It sometimes happens that you have to delete active configuration of a module due to some problems.
It is not enough to simply uninstall the module. There can still be active configuration that has relations to other objects within drupal.
we had issues with the File_Entity Module and solved it this way:

1. drush pm-uninstall file_entity
2. drush cr
3. drush en file_entity -y resulting in:

Drupal\Core\Config\PreExistingConfigException: Configuration objects (core.entity_view_mode.file.thumbnail) provided by file_entity already exist in active configuration in /var/www/html/laska/core/lib/Drupal/Core/Config/PreExistingConfigException.php:65

The error message that comes up (see above) shows you what kind of active config you have to disable and now you can use this to solve the problem using the following workaround:

  1. drush php
  2. Drupal::configFactory()->getEditable('core.entity_view_mode.file.thumbnail')->delete();
  3. exit
  4. drush en file_entity
  5. drush cr