How does module_enable works in Drush? I'm trying to automatize an install of CiviCRM and Drupal, but I'm getting so many errors! (Using PHP 7, Drush 8, Drupal 7, CiviCRM 4.7.18)

CiviCRM has a Drush extension, which calls function module_enable(array('civicrm'))

However, Drush 8 (which says is compatible with D6, D7 and D8) throws Undefined function.

I would like to know if I should downgrade my Drush 8 or what?
Can I fix this error in some way?

These are the errors I get.

Error: Call to undefined function module_enable() in drush_civicrm_install() (line 367 of /root/.drush/civicrm.drush.inc) #0               [error]
phar:///usr/local/bin/drush/includes/command.inc(422): drush_civicrm_install()
#1 phar:///usr/local/bin/drush/includes/command.inc(231): _drush_invoke_hooks(Array, Array)
#2 phar:///usr/local/bin/drush/includes/command.inc(199): drush_command()
#3 phar:///usr/local/bin/drush/lib/Drush/Boot/BaseBoot.php(67): drush_dispatch(Array)
#4 phar:///usr/local/bin/drush/includes/preflight.inc(66): Drush\Boot\BaseBoot-&gt;bootstrap_and_dispatch()
#5 phar:///usr/local/bin/drush/includes/startup.inc(458): drush_main()
#6 phar:///usr/local/bin/drush/includes/startup.inc(365): drush_run_main(false, '/', 'Phar detected. ...')
#7 phar:///usr/local/bin/drush/drush(114): drush_startup(Array)
#8 /usr/local/bin/drush(10): require('phar:///usr/loc...')
#9 {main}.
Error: Call to undefined function module_enable() in /root/.drush/civicrm.drush.inc on line 367 #0 phar:///usr/local/bin/drush/includes/command.inc(422): drush_civicrm_install()
#1 phar:///usr/local/bin/drush/includes/command.inc(231): _drush_invoke_hooks(Array, Array)
#2 phar:///usr/local/bin/drush/includes/command.inc(199): drush_command()
#3 phar:///usr/local/bin/drush/lib/Drush/Boot/BaseBoot.php(67): drush_dispatch(Array)
#4 phar:///usr/local/bin/drush/includes/preflight.inc(66): Drush\Boot\BaseBoot-&gt;bootstrap_and_dispatch()
#5 phar:///usr/local/bin/drush/includes/startup.inc(458): drush_main()
#6 phar:///usr/local/bin/drush/includes/startup.inc(365): drush_run_main(false, '/', 'Phar detected. ...')
#7 phar:///usr/local/bin/drush/drush(114): drush_startup(Array)
#8 /usr/local/bin/drush(10): require('phar:///usr/loc...')
#9 {main}
Error: Call to undefined function module_enable() in drush_civicrm_install() (line 367 of /root/.drush/civicrm.drush.inc).
Drush command terminated abnormally due to an unrecoverable error.      


Changing it to drush_module_enable() ends in another error:

Drupal\Core\Extension\MissingDependencyException: Unable to install modules civicrm due to missing modules civicrm. in                     [error]
/opt/compucorp/core/lib/Drupal/Core/Extension/ModuleInstaller.php:85
Stack trace:
#0 /opt/compucorp/core/lib/Drupal/Core/ProxyClass/Extension/ModuleInstaller.php(83): Drupal\Core\Extension\ModuleInstaller-&gt;install(Array,
true)
#1 phar:///usr/local/bin/drush/commands/core/drupal/environment.inc(131): Drupal\Core\ProxyClass\Extension\ModuleInstaller-&gt;install(Array,
true)
#2 phar:///usr/local/bin/drush/commands/core/drupal/environment.inc(198): drush_module_install(Array)
#3 /root/.drush/civicrm.drush.inc(367): drush_module_enable(Array)
#4 phar:///usr/local/bin/drush/includes/command.inc(422): drush_civicrm_install()
#5 phar:///usr/local/bin/drush/includes/command.inc(231): _drush_invoke_hooks(Array, Array)
#6 phar:///usr/local/bin/drush/includes/command.inc(199): drush_command()
#7 phar:///usr/local/bin/drush/lib/Drush/Boot/BaseBoot.php(67): drush_dispatch(Array)
#8 phar:///usr/local/bin/drush/includes/preflight.inc(66): Drush\Boot\BaseBoot-&gt;bootstrap_and_dispatch()
#9 phar:///usr/local/bin/drush/includes/startup.inc(458): drush_main()
#10 phar:///usr/local/bin/drush/includes/startup.inc(365): drush_run_main(false, '/', 'Phar detected. ...')
#11 phar:///usr/local/bin/drush/drush(114): drush_startup(Array)
#12 /usr/local/bin/drush(10): require('phar:///usr/loc...')
#13 {main}
module_enable is a Drupal 7 function - it would seem you're not running this command on a drupal 7 site.

Downgrading Drush won't have any effect, if you want to use this extension with Drupal 8 the code will need to be updated to satisfy the new API.

The new equivalent is:

\Drupal::moduleHandler()-&gt;enable(['civicrm']);