A good enhancement in Drupal 8 is having list of yml file to import via installation in mymodule_root\config\install, but this means I can not reinstall a module because the configuration settings already exist in the active configuration.

Actually the problem is when uninstalling the module: The imported configuration settings, imported during installation, aren't waived.


Test scenario

Put this sample .yml file in yourmodule_root\config\install\systme.site.yml.

name: 'Admissions at Adelaide'
mail: admin22@example.com
slogan: ''
  403: ''
  404: ''
  front: caslogin
admin_compact_mode: false
weight_select_max: 100
langcode: en
default_langcode: en
  • I deleted the values in config table directly. – digitaldonkey Dec 3 '15 at 18:39

I'm quite sure it's not best practice, but you may try to add a yourmodule.install file and add something like this:

function yourmodule_migrate_uninstall() {

  // Delete Configuration generated at at activation.
  $dir = DRUPAL_ROOT . DIRECTORY_SEPARATOR . drupal_get_path('module', 'yourmodule') . DIRECTORY_SEPARATOR . 'config/install';
  $files = file_scan_directory($dir, '/.*\.yml$/');

  foreach ($files as $file) {
      ->condition('name', $file->name)

Better answers's are welcome ;)


See How to remove mymodule configurations on uninstall for a best-practice solution.

Basically, you can enforce the dependency on your module in your configuration files. So when the module is uninstalled, it's associated configuration will be uninstalled as well.

Not the answer you're looking for? Browse other questions tagged or ask your own question.