Is there a command for Drush so I can uninstall a module from the enabled state? I hate having to drush dis mymod -y (and) drush pm-uninstall mymod -y
3 Answers
No, drush was design so you would not uninstall an enabled module. The same way Drupal was. You will have to create your own shell script to run these commands.
If you want to create your own drush command you should read this tutorial and this sample reference
-
This answer is not valid anymore. Just use drush pm-uninstall, just like pal4life said. Dec 15, 2014 at 10:17
-
1
-
1I don't think this is the case. I'm using 7.0-dev and it still prompts me to disabled before uninstalling the module. Apr 17, 2015 at 17:45
-
Another solution here if you don't want to take the alias route that Tony brought up is to use the &&
operator to do a one-liner:
drush dis -y my_module && drush pm-uninstall -y my_module
-
-
For Drupal 8 just uninstall: drush pm-uninstall -y my_module cause Drupal 8 does not support disabling modules. Oct 17, 2019 at 8:47
I'm using Drush 6.2, and pm-uninstall does not appear to disable AND uninstall a module. I thought I'd share another solution/alternative to creating a custom drush command. I was searching for the exact same thing and discovered a method using aliases and a custom bash script.
Example:
drush uninstall module_name
In drushrc.php file, add:
$options['shell-aliases']['uninstall'] = '!drushu';
And create a script (add to your $PATH), called drushu with the following:
#!/bin/bash
drush dis $1 -y
drush pm-uninstall $1 -y
If in a multi-site environment, site aliases would likely be required. Tested and works using the following... Example:
drush @site-alias uninstall module_name
In drushrc.php file, add:
$options['shell-aliases']['uninstall'] = '!drushu {{@target}}';
And in the drushu script, add:
#!/bin/bash
drush $1 dis $2 -y
drush $1 pm-uninstall $2 -y