Problem/Motivation
Module configurations are not removed properly during uninstall. Getting error bellow error on install module.
Unable to install Avatar Kit, field.field.user.user.avatars_avatar_generator, field.storage.user.avatars_avatar_generator already exist in active configuration.
Steps to reproduce
- Install Avatar Kit as normal
- Uninstall the module
- Try to install module again
- During install the error will throw and not allowing to install.
Proposed resolution
Implement hook_uninstall() to remove configuration.
Remaining tasks
Nil
User interface changes
Nil
API changes
Nil
Data model changes
Nil

| Comment | File | Size | Author |
|---|---|---|---|
| #13 | 3294517-uninstall-avatar-config.patch | 733 bytes | socialnicheguru |
| #5 | unable-reinstall-3294517-3.patch | 602 bytes | arunkumark |
| Unable-to-install.png | 112.34 KB | arunkumark |
Issue fork avatars-3294517
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #5
arunkumarkComment #6
dpiThe config should probably just be moved to optional.
Comment #7
joachim commented> The config should probably just be moved to optional.
Not sure that's the right fix.
The module should clean up after itself and delete the field -- because otherwise, going to admin/config/people/accounts/fields/user.user.avatars_avatar_generator crashes the site because the options provider is no longer available.
Comment #8
joachim commentedWe don't need to do this in an uninstall hook AFAIK -- should be able to do this by setting a config dependency on the fields created in hook_install().
And there is also the avatars_user_picture field to clean up similarly.
Comment #9
socialnicheguru commentedThis is needed as avatar persists in other config entities on the site after deletion.
Comment #10
socialnicheguru commentedWill the current patch delete these fields too:
field.field.user.user.avatars_user_picture.yml
field.storage.user.avatars_user_picture.yml
also references are added to a number of other configs.
When I uninstalled I thought that the references to avatars would be removed but it was not.
Comment #11
joachim commented> This is needed as avatar persists in other config entities on the site after deletion.
That is handled automatically by the config system if dependencies are correctly declared.
See ConfigEntityBase;:onDependencyRemoval().
Comment #12
socialnicheguru commentedit is not happening.
So how can I debug and trace dependencies to isolate the issue
Comment #13
socialnicheguru commentedrerolled and added user.avatars_user_picture which persists after uninstall with the previous patch.
Comment #14
coaston commentedPatch works fine.
However it works to uninstall module correctly. However who already uninstalled it first need to remove fields manually and then install module again:
-remove avatars_avatar_generator and avatars_user_picture manually
-refresh cache
-install module again
-uninstall module again - works.
Comment #15
coaston commentedAnother issue discovered > you cannot unisntall module if there is any role permission already assigned to submodules (i uninstalled Robot submodule and then tried to unisntall this one). However below config should be removed from robot submodule. :
Note: robot2 and robot were names of my generator.
Comment #16
shevgenyI can't delete the module, I can't disable the permission to upload avatars for the user role. Error:
The patches did not help. Drupal 10.2, module 8.x-2.x-dev, PHP 8.1.