You are here

Drush error: Drush command terminated abnormally due to an unrecoverable error

Submitted by blogdev on Fri, 28/02/2014 - 10:03

Executing drush -d status results in this error.

Drush bootstrap phase : _drush_bootstrap_drupal_site() [0.12 sec, 7.41 MB]                                                                                [bootstrap]
Initialized Drupal site default at sites/default [0.12 sec, 7.41 MB]                                                                                         [notice]
Cache HIT cid: 5.7-commandfiles-2-c32acd775c18a90c5b41d0fc9accf5ab [0.13 sec, 7.41 MB]                                                                        [debug]
Drush bootstrap phase : _drush_bootstrap_drupal_configuration() [0.13 sec, 7.41 MB]                                                                       [bootstrap]
Drush bootstrap phase : _drush_bootstrap_drupal_database() [0.16 sec, 9.16 MB]                                                                            [bootstrap]
Successfully connected to the Drupal database. [0.16 sec, 9.16 MB]                                                                                        [bootstrap]
Drush bootstrap phase : _drush_bootstrap_drupal_full() [0.17 sec, 9.16 MB]                                                                                [bootstrap]
Undefined index: sitename domain.module:2922 [1.24 sec, 31.05 MB]                                                                                            [notice]
Undefined index: path domain.module:2923 [1.24 sec, 31.05 MB]                                                                                                [notice]
Drush command terminated abnormally due to an unrecoverable error. [1.24 sec, 31.06 MB]                                                                   [error]

As there isn't much debugging related in the output it is better to check the error log. Executing php -i show that the error log location is not set. Is there a way to pass an error log setting to the drush command either via some drush parameter or invoke drush via PHP together with an error log setting on the command line?
The drush parameter list doesn't show any option for adding php.ini settings such as with the -d option to PHP, but it has the option for specifying an alternate php.ini. As the I want to use one off settings it is better to find a way to pass some -d options to drush.

After examining /usr/bin/drush it may be better to modify it to take additional php.ini parameters to pass on to the drush invocation via the $php_options variable. It turns out to be possible but entails radical changes to the drush script.

Final Solution
On examining the code I thought it may be a good idea to add additional custom parameters and modify the drush shell script to extract them. In the last exec call to drush all the original parameters are passed to php using '$@'. It is an interesting bash challenge to extract your custom parameters into the $php-options variable and pass an amended $@, but not quite necessary here.

Stack Exchange results are below. The first link provides a good solution answer.

http://drupal.stackexchange.com/questions/105166/is-there-a-way-to-pass-...
http://drupal.stackexchange.com/questions/105121/is-there-a-means-to-pas...
http://tldp.org/LDP/abs/html/othertypesv.html
http://tldp.org/LDP/Bash-Beginners-Guide/html/sect_09_07.html

/usr/bin/drush.php

#!/usr/bin/env sh
#
# This script is a simple wrapper that will run Drush with the most appropriate
# php executable it can find.
#
# Solaris users: Add /usr/xpg4/bin to the head of your PATH
#
 
# Get the absolute path of this executable
SELF_DIRNAME="`dirname -- "$0"`"
SELF_PATH="`cd -P -- "$SELF_DIRNAME" && pwd -P`/`basename -- "$0"`"
 
# Decide if we are running a Unix shell on Windows
if [ "`which uname /dev/null 2>&1`" ]; then
  case "`uname -a`" in
    CYGWIN*)
      CYGWIN=1 ;;
    MINGW*)
      MINGW=1 ;;
  esac
fi
 
# Resolve symlinks - this is the equivalent of "readlink -f", but also works with non-standard OS X readlink.
while [ -h "$SELF_PATH" ]; do
    # 1) cd to directory of the symlink
    # 2) cd to the directory of where the symlink points
    # 3) Get the pwd
    # 4) Append the basename
    DIR="`dirname -- "$SELF_PATH"`"
    SYM="`readlink $SELF_PATH`"
    SYM_DIRNAME="`dirname -- "$SYM"`"
    SELF_PATH="`cd "$DIR" && cd "$SYM_DIRNAME" && pwd`/`basename -- "$SYM"`"
done
 
# Build the path to drush.php.
SCRIPT_PATH=/usr/share/php/drush/drush.php
if [ -n "$CYGWIN" ] ; then
  SCRIPT_PATH="`cygpath -u -a -- "$SCRIPT_PATH"`"
fi
 
# If not exported, try to determine and export the number of columns.
# We do not want to run `tput cols` if $TERM is empty or "dumb", because
# if we do, tput will output an undesirable error message to stderr.  If
# we redirect stderr in any way, e.g. `tput cols 2>/dev/null`, then the
# error message is suppressed, but tput cols becomes confused about the
# terminal and prints out the default value (80).
if [ -z $COLUMNS ] && [ -n "$TERM" ] && [ "$TERM" != dumb ] && [ -n "`which tput`" ] ; then
  # Note to cygwin/mingw/msys users: install the ncurses package to get tput command.
  # Note to mingw/msys users: there is no precompiled ncurses package.
  if COLUMNS="`tput cols`"; then
    export COLUMNS
  fi
fi
 
if [ -n "$DRUSH_PHP" ] ; then
  # Use the DRUSH_PHP environment variable if it is available.
  php="$DRUSH_PHP"
else
  # On MSYSGIT, we need to use "php", not the full path to php
  if [ -n "$MINGW" ] ; then
    php="php"
  else
    # Default to using the php that we find on the PATH.
    # We check for a command line (cli) version of php, and if found use that.
    # Note that we need the full path to php here for Dreamhost, which behaves oddly.  See http://drupal.org/node/662926
    php="`which php-cli 2>/dev/null`"
 
    if [ ! -x "$php" ]; then
      php="/usr/bin/php"
    fi
 
    if [ ! -x "$php" ]; then
      echo "ERROR: can't find php."; exit 1
    fi
  fi
fi
 
# Check to see if the user has provided a php.ini file or drush.ini file in any conf dir
# Last found wins, so search in reverse priority order
for conf_dir in "`dirname "$SELF_PATH"`" /etc/drush "$HOME/.drush" ; do
  if [ ! -d "$conf_dir" ] ; then
    continue
  fi
  # Handle paths that don't start with a drive letter on MinGW shell. Equivalent to cygpath on Cygwin.
  if [ -n "$MINGW" ] ; then
    conf_dir=`sh -c "cd \"$conf_dir\"; pwd -W"`
  fi
  if [ -f "$conf_dir/php.ini" ] ; then
    drush_php_ini="$conf_dir/php.ini"
  fi
  if [ -f "$conf_dir/drush.ini" ] ; then
    drush_php_override="$conf_dir/drush.ini"
  fi
done
# If the PHP_INI environment variable is specified, then tell
# php to use the php.ini file that it specifies.
if [ -n "$PHP_INI" ] ; then
  drush_php_ini="$PHP_INI"
fi
# If the DRUSH_INI environment variable is specified, then
# extract all ini variable assignments from it and convert
# them into php '-d' options. These will override similarly-named
# options in the php.ini file
if [ -n "$DRUSH_INI" ] ; then
  drush_php_override="$DRUSH_INI"
fi
 
# Add in the php file location and/or the php override variables as appropriate
if [ -n "$drush_php_ini" ] ; then
  php_options="--php-ini $drush_php_ini"
fi
if [ -n "$drush_php_override" ] ; then
  php_options=`grep '^[a-z_A-Z0-9.]\+ *=' $drush_php_override | sed -e 's|\([^ =]*\) *= *\(.*\)|\1="\2"|' -e 's| ||g' -e 's|^|-d |' | tr '\n\r' '  '`
fi
# If the PHP_OPTIONS environment variable is specified, then
# its contents will be passed to php on the command line as
# additional options to use.
if [ -n "$PHP_OPTIONS" ] ; then
  php_options="$php_options $PHP_OPTIONS"
fi
 
# Always disable magic_quotes_gpc and friends
php_options="$php_options -d magic_quotes_gpc=Off -d magic_quotes_runtime=Off -d magic_quotes_sybase=Off"
 
# Pass in the path to php so that drush knows which one to use if it
# re-launches itself to run subcommands.  We will also pass in the php options.
# Important note: Any options added here must be removed  when Drush processes
# a #! (shebang) script.  @see drush_adjust_args_if_shebang_script()
exec "$php" $php_options "$SCRIPT_PATH" --php="$php" --php-options="$php_options" "$@"