Scroll
Drush shows error: Support bash to support 'source' with fallback on $0 if this does not run with bash
I have huge number of configs and run usually config import with php -d memory_limit=-1 (disable memory limit for PHP):
php -d memory_limit=-1 ./vendor/bin/drush config-import -y
But this time I got an error:
# Support bash to support `source` with fallback on $0 if this does not run with bash
# https://stackoverflow.com/a/35006505/6512
selfArg="$BASH_SOURCE"
if [ -z "$selfArg" ]; then
selfArg="$0"
fi
self=$(realpath $selfArg 2> /dev/null)
if [ -z "$self" ]; then
self="$selfArg"
fi
dir=$(cd "${self%[/\\]*}" > /dev/null; cd ../drush/drush && pwd)
if [ -d /proc/cygdrive ]; then
case $(which php) in
$(readlink -n /proc/cygdrive)/*)
# We are in Cygwin using Windows php, so the path must be translated
dir=$(cygpath -m "$dir");
;;
esac
fi
export COMPOSER_RUNTIME_BIN_DIR="$(cd "${self%[/\\]*}" > /dev/null; pwd)"
# If bash is sourcing this file, we have to source the target as well
bashSource="$BASH_SOURCE"
if [ -n "$bashSource" ]; then
if [ "$bashSource" != "$0" ]; then
source "${dir}/drush" "$@"
return
fi
fi
"${dir}/drush" "$@"
You can avoid this error if you will send memory_limit=-1 as php-options:
./vendor/bin/drush --php-options='-d memory_limit=-1' config-import -y
Why php -d memory_limit=-1 vendor/bin/drush …
now explodes
By forcing the file through php
, you tell the PHP interpreter to parse a bash script:
php -d memory_limit=-1 ./vendor/bin/drush status
PHP dutifully tries to execute the first non-PHP line (# Support bash …
) and immediately dies, printing the wrapper’s source to the screen. That is exactly the output you pasted. The change was introduced in Drush 13.3 and is discussed in the upstream issue “Running drush as php script fails after updating from 13.2.0”