2

I want to uninstall the Field module, but this module can not be uninstalled; when I try, I get the following message.

Field API to add fields to entities like nodes and users. Machine name: field Version: 8.0.6 Required by: TextNodeAdmin ToolbarAdmin Toolbar Extra ToolsFileOptionsAggregator (disabled) ImageAccelerated Mobile Pages (AMP) (disabled)Custom BlockBook (disabled)Text EditorCKEditorCommentInterface TranslationConfiguration Translation (disabled)

How do I forcefully uninstall any module that is having dependency or content inside, for example the Node module, the Views module, or any entity having content in it?

I tried using \Drupal::service('module_installer')->uninstall(['admin_toolbar']); but then my site breaks.

  • 1
    Is there a reason why you want to uninstall this crucial module? – No Sssweat Jul 5 '16 at 9:58
  • I'm just experimenting things as how one can remove all traces of any installed module by some piece of code. – Sugandh Khanna Jul 5 '16 at 10:02
  • Doing it with the UI with a minimal installation, I ran into a dead end. I can't uninstall Text, which in turn it won't allow me to uninstall Field. Also, as you can tell, it appears Field is the super module/heart of Drupal Core. – No Sssweat Jul 5 '16 at 10:12
  • Its not about jss one module - Fields, this is a generic question, I can't figure out as how to uninstall any module which is built with entity concept and entity having content. For example, I made any custom content entity type and add content into it. Now I can not uninstall my custom module until and unless I delete all content or truncate module specific db table. Hope you get my point. – Sugandh Khanna Jul 5 '16 at 10:17
  • 1
    @SugandhKhanna Yes, that's what you would expect to happen. No, you can't remove a module on which existing parts of the system depends. The only way to remove a part of the system on which a second part of the system depends, is to remove that second part first. It's what dependencies are. If you could just remove the field system when there are existing fields, or remove the module that provides content without removing the content, then they wouldn't be dependencies any more. They'd be optional. And in the context of fields/nodes/etc, that wouldn't make sense – Clive Jul 5 '16 at 10:24
2

For example, I made any custom content entity type and add content into it. Now I can not uninstall my custom module until and unless I delete all content or truncate module specific db table – Sugandh Khanna.

Unfortunately, in Drupal 8 you can't disable a module, like you can in Drupal 7.

In Drupal 7 you need to disable the module first, which means all module related code stays in DB. Then, if you wanted, you Uninstall to remove everything from DB.

In Drupal 8 the only option is to uninstall the module, which means you have to destroy all traces of your module from the Database. You cannot just disable the module anymore.

Also, to uninstall Flag (as in your comment here), you have to uninstall dependencies first, then and only then, it will allow you to uninstall Flag. Because if module X depends on Flag and somehow you removed flag, it will totally screw up module X, X becomes useless, module X is nothing without Flag. Therefore you need to remove module X first, then and only then it will allow you to remove Flag.

For more info: Why can't I uninstall modules in Drupal 8? (Explained)

Issue: Disabled modules are broken beyond repair so the "disable" functionality needs to be removed

| improve this answer | |
  • Thanks @No Sssweat. So the final conclusion is we can not uninstall dependencies. Or It is just impossible to uninstall Flag – Sugandh Khanna Jul 5 '16 at 10:41
  • 2
    @SugandhKhanna you have to uninstall dependencies first, then and only then, it will allow you to uninstall Flag. Because if module X depends on Flag and somehow you removed flag, it will totally screw up module X, X becomes useless, module X is nothing without Flag. Therefore you need to remove module X first, then and only then it will allow you to remove Flag. – No Sssweat Jul 5 '16 at 10:44

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.