Drush ignoring `$options['config']` statement in drushrc file from the 'drush' folder at the root of the current git repository I'm a long-time browser, first-time poster.

I have a Drupal 7 site set-up using Drupal-Boilerplate structure in a Git repository. I defined some settings in the drush/drushrc.php file. The documentation indicates:


  “Drush doesn't by default know to search this directory. To work around that we need to add this awesome snippet to our local drushrc.php file.”


I added the provided snippet to docroot/sites/all/drush/drushrc.php. But the $options['config'] statement seems to be ignored. The settings defined in drush/drushrc.php are not taking effect.

I believe that the code is correctly defining the root of the Git repository. The $options['alias-path'] statement seems to take effect as the “example” aliases appear when I run drush site-alias. The $options['include'] statement also seems to take effect as the devify command defined in drush/commands/build.drush.inc is available.

The configuration options I have specified in drush/drushrc.php are not taking effect. When I run drush status, the “Drush configuration” lists docroot/sites/all/drush/drushrc.php and my user-specific drushrc.php from my home directory. I would expect to also see the drush/drushrc.php file listed.

I have tried executing git rev-parse --show-toplevel. That returns the correct path to the root of the Git repository. I tried explicitly adding the drush/drushrc.php file by adding the full path in an $options['config'] statement in docroot/sites/all/drush/drushrc.php. None of that seems to have been effective.

I’m at my wits end with this. Please help me StackExchange!

I’m using


Drush 6.3.0
Drupal 7.28
PHP 5.5.11
Windows 8
As Clive said, the snipped goes in $HOME/.drush/drushrc.php, not in the drushrc.php file in your site folder.  The drushrc.php in your site folder does not get parsed until Drush bootstraps your site; by that time, it's too late to add items to the 'config' list, as it has already been processed.

Also, in place of:

$repo_dir = drush_get_option('root') ? drush_get_option('root') : getcwd();

... it would probably be better if the snippet used:

$repo_dir = drush_get_context('DRUSH_SELECTED_DRUPAL_ROOT') ? drush_get_context('DRUSH_SELECTED_DRUPAL_ROOT') : getcwd();

Finally, rather than setting the 'config' option, which is gitchy and a little high-strung, you could just include your drushrc.php directly.

Replace:

$options['config'] = $repo . '/drush/drushrc.php';

with:

include $repo . '/drush/drushrc.php';

Then you could go back to putting this snippet in your sites/all/drush/drushrc.php, if that's working better for you.