17

I am creating on Drupal 8 module. I have used a custom table to store the data collected from forms. Somehow during installation, tables are not created due to an issue in the install file. Now I have fixed the issue, and I want to install the module again.

How can I re-install a module?

From this and this discussions, I know the Disable module functionality has been removed.

Is there any other way to re-install a module so that its database tables are created?

0

5 Answers 5

22

The Devel module can also help here.

It makes a "Reinstall modules" page available at /devel/reinstall, which lets you re-install modules in bulk.

It's also worth mentioning Drush; dis (obviously) doesn't work any more, but pm-uninstall and en still do. And if you have Devel installed, you can invoke a reinstall with

drush dre module1 module2
3
  • Note that devel doesn't yet support Drupal 8's uninstall-only changes cgit.drupalcode.org/devel/tree/drush/devel.drush.inc#n115
    – anavarre
    Jun 25, 2014 at 10:12
  • 1
    I've started an issue to fix that drupal.org/node/2292425
    – anavarre
    Jun 25, 2014 at 12:23
  • I think all the answers posted here are incorrect. The original question is how to "re-install". This is not the same as how to uninstall and then install. All the scenarios here, sadly, do an uninstall which is a major step backwards for D8 as this will wipe the configuration for that module. I'm still looking for the correct answer of how to "re-load" the install config for a module (without uninstall).
    – liquidcms
    Mar 26, 2020 at 20:00
10

As you said "Disable functionality is removed from Drupal 8" ..

The short answer is - you probably are looking for the "Uninstall" tab found on the "Extend" (Modules) page /admin/modules/uninstall

There is no longer any grey area between a module being on and active vs off and "purged". "Disabled" is no longer a thing. Uninstalling a module means removing all traces of it.

Go to admin/modules/uninstall and uninstall module... Then enabled the module from modules list page. That should install the module again.

For Example ....

Before Installing Ban Module in Drupal 8 ... ban_ip module doesn't exist in database..

enter image description here enter image description here

After Installing Ban Module in Drupal 8... ban_ip table is created and module cannot be disabled but can be uninstalled in admin/modules/uninstall

enter image description here enter image description here enter image description here

Now if you uninstall module.. Table will be removed from database and module can be installed again which will create tables in the database..

enter image description here enter image description here

1
  • Thanks a lot for such awesome explanation. I checked the list of modules in uninstall tab, but couldn't found my module. If you want to check code here github.com/mohit-rocks/messaging . Currently you can install module and settings related forms are coming. May 10, 2014 at 9:34
5

Solution 1: Uninstall and Install again manually

Using the Drupal UI:

  • Go to the Extend page from the admin menu
  • Go to the uninstall module page
  • Uninstall the module you wish to
  • Go to the Extend page again (where you have a list of modules)
  • Install the module you just uninstalled

Using Drush (you should try it if you don't use it):

  • drush pm-uninstall MODULE -y && drush pm-enable MODULE -y
  • OR in short drush pmu MODULE -y && drush en MODULE -y

Replace MODULE with the name of your module.

Solution 2: Reinstall using Devel module

Assuming you have the devel module installed.

Using Drupal UI:

  • Visit the path /devel/reinstall
  • Re-install the modules you wish to

Using Drush:

  • drush devel-reinstall MODULE -y
  • OR in short drush dre MODULE -y

Replace MODULE with the name of your module.

5

If you want to re-install (reload) the install config for a specific module you can use this drush command:

drush cim --partial --source=modules/custom/MY_MODULE/config/install
3
  • This got me excited but it doesn't work for me, I keep getting errors about the source dir not existing.
    – Christian
    Jul 28, 2020 at 2:59
  • What is the your source dir? And i guess it would require that the module has a config/install dir. If it doesn't; then likely there is nothing to re-install for that module.
    – liquidcms
    Jul 28, 2020 at 22:09
  • I tried relative and absolute paths to the dir, on my local machine and my VM. Module has config dir with yml files. Ended up using drupal console and config:import:single. Thanks
    – Christian
    Jul 30, 2020 at 0:53
2

If nothing else works you can try the below for Drupal 8.

  1. Remove the problematic module files and it's folder

    • rm -rf modules/your_problematic_module
  2. Remove the cached twig templates

    • rm -rf sites/default/files/php
  3. Clear the Drupal cache

NOTE: Make sure to backup the code and Database before doing this

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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