Drush scripting fails on call to drush_pm_enable() I'm trying to script the automatic download and install of a set of modules for a Drupal 7 site.

At this point, I have Drupal and all desired modules downloading using a drush make profile, and installation of the site by calling drush_invoke_process on site-install.

I'm trying to get the downloaded modules activated after the installation of the site.  I have tried a number of things, the latest of which is:

(code here...)
drush_bootstrap(DRUSH_BOOTSTRAP_DRUPAL_FULL);
drush_set_context('PM_ENABLE_MODULES',array('ctools', 'views', 'views_ui'));
drush_pm_enable();
(code here...)


Every attempt to enable the downloaded modules results in the following error:


  PHP Fatal error:  Call to undefined function drush_module_enable() in
  /Users/lhridley/sp/Drupal/tools/drush/commands/pm/pm.drush.inc on line
  904


Any ideas?
The Drupal and Drush bootstrap processes are fairly complicated things; it is best no to try to figure out how to call them yourself.  If you want to bootstrap and call arbitrary PHP code, you can do so using Drush via drush @mysite ev 'php code here'.

As for calling Drush code directly, you should use drush_invoke_process, just as you are for the site-install command.  So, instead of drush_pm_enable(), instead use drush_invoke_process("@self", "pm-enable", array('ctools', 'views', 'views_ui')).

However, if you are running site-install on an installation profile, you should not need to call pm-enable, as the installation profile should take care of that for you.  If you're not sure how to build an installation profile, you can have Drush generate one for you.  You'll need to use the prototype generate-profile command, which can be found at http://drupal.org/node/1368242.  It does not work for D6 sites yet, but works fine for D7, so should be good for your purposes. Take a look at the list of modules generated in your profilename.info file; these will be enabled for you during site-install.