Unable to re-install Avatar Kit module

Created on 6 July 2022, over 2 years ago
Updated 5 May 2024, 7 months ago

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

  1. Install Avatar Kit as normal
  2. Uninstall the module
  3. Try to install module again
  4. 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

🐛 Bug report
Status

Active

Version

2.0

Component

Code

Created by

🇮🇳India arunkumark Coimbatore

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.

  • 🇬🇧United Kingdom joachim

    > 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.

  • 🇬🇧United Kingdom joachim
    +++ b/avatars.install
    @@ -15,3 +15,13 @@ function avatars_install() {
    +  // Remove configuration related to Avatar module.
    

    We 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.

  • 🇺🇸United States SocialNicheGuru

    This is needed as avatar persists in other config entities on the site after deletion.

  • 🇺🇸United States SocialNicheGuru

    Will the current patch delete these fields too:
    field.field.user.user.avatars_user_picture.yml
    field.storage.user.avatars_user_picture.yml

  • 🇬🇧United Kingdom joachim

    > 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().

  • 🇺🇸United States SocialNicheGuru

    it is not happening.

    So how can I debug and trace dependencies to isolate the issue

  • Status changed to Needs review over 1 year ago
  • 🇺🇸United States SocialNicheGuru

    rerolled and added user.avatars_user_picture which persists after uninstall with the previous patch.

  • 🇸🇰Slovakia coaston

    for me it still does not work. Firs you need to install it so you can unistall it. But once uninstalled already without that patch it is not possible to install that module again and then try to correctly uninstall it.

  • Status changed to Active about 1 year ago
  • 🇸🇰Slovakia coaston

    Another issue discovered > you cannot unisntall module if there is any role permission already assigned :

    RuntimeException: Adding non-existent permissions to a role is not allowed. The incorrect permissions are "avatars avatar_generator user robot", "avatars avatar_generator user robot2". in Drupal\user\Entity\Role->calculateDependencies() (line 207 of core\modules\user\src\Entity\Role.php).
    Drupal\Core\Config\ConfigManager->getConfigEntitiesToChangeOnDependencyRemoval('module', Array) (Line: 43)
    Drupal\system\Form\ModulesUninstallConfirmForm->addDependencyListsToForm(Array, 'module', Array, Object, Object) (Line: 160)
    Drupal\system\Form\ModulesUninstallConfirmForm->buildForm(Array, Object)
    call_user_func_array(Array, Array) (Line: 536)
    Drupal\Core\Form\FormBuilder->retrieveForm('system_modules_uninstall_confirm_form', Object) (Line: 283)
    Drupal\Core\Form\FormBuilder->buildForm(Object, Object) (Line: 73)
    Drupal\Core\Controller\FormController->getContentResult(Object, Object)
    call_user_func_array(Array, Array) (Line: 123)
    Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 583)
    Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 124)
    Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
    Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 182)
    Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 76)
    Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 58)
    Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 48)
    Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 106)
    Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 85)
    Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 48)
    Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 51)
    Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 51)
    Drupal\Core\StackMiddleware\StackedHttpKernel->handle(Object, 1, 1) (Line: 704)
    Drupal\Core\DrupalKernel->handle(Object) (Line: 19)
    
  • 🇷🇺Russia shevgeny Moscow

    I can't delete the module, I can't disable the permission to upload avatars for the user role. Error:

    RuntimeException: Adding non-existent permissions to a role is not allowed. The incorrect permissions are "avatars avatar_generator user gravatar", "avatars avatar_generator user gravatar_generator", "avatars avatar_generator user robohash". in Drupal\user\Entity\Role->calculateDependencies() (line 207 of /web/core/modules/user/src/Entity/Role.php).

    The patches did not help. Drupal 10.2, module 8.x-2.x-dev, PHP 8.1.

Production build 0.71.5 2024