Drush command terminated abnormally due to an unrecoverable error


This error might be very frustrating to you, specially when you can’t see any issue with your code, can’t check error log, and obviously can’t do drush watchdog-show.

After some search and investigation, found that I had a call to drupal_goto() in an implementation for hook_init() which is implemented on every bootstrap process.

The solution was to add a condition to check before doing the drupal_goto() to check that the source is not from drush:

if (!function_exists(‘drush_main’) &&  /* other conditions */ ) {
drupal_goto($redirect_path);
drupal_exit();
}

Leave a comment