Deploying module removal (files) often results in a configuration that cannot be imported

Created on 26 November 2018, about 6 years ago
Updated 3 August 2023, over 1 year ago

It is impossible for a Drupal project that uses both configuration management files and composer to safely remove a module.

Consider the following situation:

  1. A developer uninstalls a module in Drupal
  2. Exports configuration
  3. Removes the module using composer
  4. Pushes changes

When a second developer or production environment for that matter pulls the changes the database contains the installation so when a config import is done an uninstall is triggered. This is where the bug lives.
In order to have a working installation the second developer needs to do a config import before composer install. The other way around will result in files missing required for the uninstall procedure. This is annoying as you can't have a repeatable build procedure but things get impossible when the first developer or another developer also added a module.
Now a config import will fail if you do not do a composer install (because it wants to enable a missing module) and will still fail if you do a composer install because it cannot perform the uninstall of the removed module in Drupal.

There should be a separate command to handle the uninstall config changes. This way we can always perform these steps without issue:

  1. drush config-uninstall-pending
  2. composer install
  3. drush config-import
πŸ› Bug report
Status

Closed: won't fix

Version

11.0 πŸ”₯

Component
ConfigurationΒ  β†’

Last updated 7 days ago

Created by

πŸ‡³πŸ‡±Netherlands karel010

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡¦πŸ‡ΊAustralia acbramley

    Modules must be uninstalled with the module code in place to allow various hooks to run (e.g hook_uninstall)

    Developers can pick and choose how they go about uninstalling and removing modules. You can simply do it in 2 steps (deploy through the uninstallation, then later composer removal), there is no reason that I can think of where you can't do this.

    If you really want to remove it in 1 deployment you can use stub files where you create a stub module directory in your custom modules with nothing but a .info.yml file. This can then be deleted later.

    In any case, I don't think this is something that can/should be fixed in core.

Production build 0.71.5 2024