drush uninstall clearer error message
ChrisRut - November 4, 2009 - 17:32
| Project: | Drush |
| Version: | All-Versions-HEAD |
| Component: | Code |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed |
Description
When a module is already uninstalled it spits out the error "x is not disabled" (where x is the name of the module). Instead of telling the user that the module has ALREADY been uninstalled.
Here's an example case:
$ drush dl share
Project share (6.x-2.0-alpha2) downloaded to [success]
/home/chris/workspace/fjdev/sites/all/modules/.
$ drush uninstall share
The following modules will be uninstalled: share
Do you really want to continue? (y/n): y
share is not disabled. If active, use `disable` command before [error]
`uninstall`.
An error occurred at function : drush_pm_uninstall [error]
$ drush enable share
The following modules will be enabled: share
Do you really want to continue? (y/n): y
Share was enabled successfully. [ok]
$ drush uninstall share
The following modules will be uninstalled: share
Do you really want to continue? (y/n): y
share is not disabled. If active, use `disable` command before [error]
`uninstall`.
An error occurred at function : drush_pm_uninstall [error]
$ # This is the correct error to give in this case because the module was enabled and never disabled prior to trying to uninstall...
$ drush disable share
The following modules will be disabled: share
Do you really want to continue? (y/n): y
Share was disabled successfully. [ok]
$ drush uninstall share
The following modules will be uninstalled: share
Do you really want to continue? (y/n): y
share was successfully uninstalled. [ok]
$ # GREAT, Drush successfully uninstalled the module !!!
$ drush uninstall share
The following modules will be uninstalled: share
Do you really want to continue? (y/n): y
share is not disabled. If active, use `disable` command before [error]
`uninstall`.
An error occurred at function : drush_pm_uninstall [error]
$ # EWW, Drush thinks the module is enabled, when it's really just been uninstalled in the prior command...
$ # Why does Drush think this module is enabled?So to sum up, drush thinks all modules that are already uninstalled, need to be disabled?

#1
I forgot to comment after line 9, you'll notice that if the module is never enabled in the first place, and the user trys to "uninstall" it it spits out the same error about the module not being disabled.
Suggestion Solution:
Have uninstall call "pm_module_status" to check and see if the module is already disabled, and if so then report "Module is not currently installed", if not then report "you must 'disable' before you 'uninstall'"
#2
Same problem here.. lucky I searched instead of opening a new bug ;-)
This is my case:
[moodle@aabsrv ~/drupal/sites/all]$ drush download chatroomProject chatroom (6.x-1.0-beta10) downloaded to /www/agriregioni/elearning/drupal/sites/all/modules/. [success]
[moodle@aabsrv ~/drupal/sites/all]$ drush uninstall chatroom
The following modules will be uninstalled: chatroom
Do you really want to continue? (y/n): y
chatroom is not disabled. If active, use `disable` command before `uninstall`. [error]
An error occurred at function : drush_pm_uninstall [error]
[moodle@aabsrv ~/drupal/sites/all]$ drush disable chatroom
Chat Room is already disabled. [warning]
There were no modules that could be disabled. [ok]
So, basically, it is not clear what to do to remove a package that has never been enabled!
#3
@ChrisRut pm_module_status only prints a table of all available modules. it is actually the drush_get_modules() function that will give the right info.
I created a patch to do it, but I am not sure if it'll be picked up because the uninstall function (as stated in the function comments) should be 'minimalist'.
#4
@sndev,
Thanks for the clarification and the patch.
-Chris
#5
committed. thx.
#6
Automatically closed -- issue fixed for 2 weeks with no activity.