Why is the drush views-list command complaining (incorrectly) that views is not enabled? I am running drush version 5.3:

rob@drupaldev:/var/www/drupal$ sudo drush version
drush version 5.3


When I attempt to execute the views-list command it says that the views module is note enabled.

rob@drupaldev:/var/www/drupal$ sudo drush views-list
Command views-list needs the following module(s) enabled to run:     [error]
views.
The drush command 'views-list' could not be executed.                [error]


However, the module is already enabled:

rob@drupaldev:/var/www/drupal$ sudo drush pm-list|grep -i views
 Chaos tool   Views content panes              Module  Not installed  7.x-1.0 
 suite        (views_content)                                                 
 Views        Views (views)                    Module  Enabled        7.x-3.3 
 Views        Views UI (views_ui)              Module  Enabled        7.x-3.3 


Any ideas what else could be causing this?

Greg suggested that it could be a permissions issue or an environment issue caused by the necessity of using sudo. After having fixed one of my permission issues, I can reliably run drush with or without sudo. In either case it returns true.

rob@drupaldev:/var/www/drupal$ sudo drush ev 'var_export(module_exists("views"));'
truerob@drupaldev:/var/www/drupal$ drush ev 'var_export(module_exists("views"));'
truerob@drupaldev:/var/www/drupal$
This is working just fine for me on a d7 site using Drush 5.4.  You are getting that message because module_exists("views") is returning false.  Your next example shows that views is enabled, which implies that module_exists("views") should be returning true.  Perhaps your site is not always bootstrapping cleanly under Drush?

Try:

drush ev 'var_export(module_exists("views"));'


Add on the 'sudo' as you do above, if you really need it.  The sudo does give me pause; I prefer to set up my permissions in such a way as to allow Drush to run without it.  Sometimes sudo changes your environment subtly (e.g. your $PATH may change), although I cannot think of a reason why it would cause you trouble in this instance.  In any event, if the test above returns 'true', then you've stumped me.  If it returns 'false', it indicates that there is something inconsistent or incorrect about your environment.  You'll have to dig deeper to find out what it is.

Edit: I'm wrong, there could be other reasons why you are getting that error, even if module_exists("views") returns 'true'.  It probably boils down to drush_bootstrap_to_phase() failing when called from _drush_bootstrap_and_dispatch(); however, I can't imagine why this would fail for views-list, but work for pm-list.  More data is needed.

Edit 2: Try again with Drush All-versions-5.x-dev (or check out head of master from git).  This is usually the first thing I suggest, but I thought that none of this code had changed recently. Turns out that enabling / disabling a module now clears the cache, but this feature was added after Drush-5.4 went out.  drush cc drush should do the trick in the interim, but you won't need to explicitly do this in the future.