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

ChrisRut - November 5, 2009 - 16:56

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

sylvaticus - November 18, 2009 - 08:45

Same problem here.. lucky I searched instead of opening a new bug ;-)

This is my case:

[moodle@aabsrv ~/drupal/sites/all]$ drush download chatroom
Project 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

sndev - November 19, 2009 - 20:02
Title:drush uninstall = not very smart» drush uninstall clearer error message
Version:All-Versions-2.1» All-Versions-HEAD
Status:active» needs review

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

AttachmentSize
better_uninstall_message.0.patch 1.76 KB

#4

ChrisRut - November 20, 2009 - 15:53

@sndev,
Thanks for the clarification and the patch.
-Chris

#5

moshe weitzman - November 21, 2009 - 21:18
Status:needs review» fixed

committed. thx.

#6

System Message - December 5, 2009 - 21:20
Status:fixed» closed

Automatically closed -- issue fixed for 2 weeks with no activity.

 
 

Drupal is a registered trademark of Dries Buytaert.