8

I have an issue disabling modules, I've searched but cannot find something useful:
- Developer A disable module and via composer remove it
- I pull his changes so i run composer install that remove the code, then drush cim to update configuration, but it complains that the module is missing while it's trying to delete its configurations.

What's the right way to do this? I can't import config before running composer install because along the uninstalled module there could be also new modules needed for the configuration import.

6

You need two consecutive releases for stuff like that.

First release:

Your colleague uninstalls the module and commits the updated config.

If you don't manage your site via config use hook_update_N instead.

/**
 * Uninstall SOME_MODULE module.
 */
function MYMODULE_update_8001(&$sandbox) {

  \Drupal::service('module_installer')->uninstall(['SOME_MODULE']);
}

Second release:

The module can be removed via Composer.


Related:

Order of drush commands for automated deployment?

| improve this answer | |
6

Adding an alternative solution to @leymannx - you will still need two releases. This is taking into consideration your mention of drush cim

First release:

  1. Uninstall the module drush pmu module_name
  2. Export the configuration.
  3. Commit, push, and release.
  4. Deploy and execute drush cim. That should uninstall the module.

A hacky way to uninstall is directly editing the core.extension.yml, remove the complete entry of the module from under the module: key, and executing drush cim. NOTE: Use this hacky way only when you are sure that the module doesn't export any configuration. Else, there would be an exception thrown.

Second release:

Removing module from composer.

| improve this answer | |
  • Thanks, it seems to me that the accepted answer is more "safe" but this could be helpful. While developing without an actual release online should be ok to speed up and avoid a lot of code, and errors can be handled easily. – Francesco Oct 19 '18 at 12:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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