Skip to main content
1 of 2
Ahmad
  • 2.8k
  • 3
  • 36
  • 83

How to remove mymodule configurations when uninstall

I have created a custom module and created a yml file to create a menu

system.menu.custom_menu.yml

id: custom_menu
label: 'Custom menu'
description: 'Custom menu.'
langcode: en
locked: true
dependencies:
  - mymod

When I installed my module it creates the the custom menu. But then When I uninstall the module and try to install it again I get the following exception

exception 'Drupal\Core\Config\PreExistingConfigException' with message 'Configuration objects (system.menu.custom_menu) provided by mymod already exist in active configuration' in
/var/www/drupal8/core/lib/Drupal/Core/Config/PreExistingConfigException.php:70

What I am doing wrong? Is there any way to remove my configuration (system.menu.custom_menu) from the configurations when I uninstall my module?

Ahmad
  • 2.8k
  • 3
  • 36
  • 83