1

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
  • Welcome to Drupal Answers :) As I understand the docs you need add the snippet to your local drushrc.php (i.e. the one in your home folder), and that will allow drush to discover a file in the root of your Drupal installation (not in sites/all). Have I misunderstood something? – Clive Jun 5 '14 at 17:44
  • Thanks, @Clive. If I’m interpreting the code correctly, the snippet should point Drush at the root of the Git repository as captured in $repo. But, even still, specifying the file path of the drushrc.php file to include did not make a difference. – dnugent-psu Jun 5 '14 at 20:21
1

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.

  • Thanks, @greg_l_anderson. Based on your answer and @Clive’s, adding the snippet to my local file without the snippet in sites/all eliminated the aliases and commands. Adding the snippet in both my local file and sites/all was the same behavior as reported in my original question. Drush seems to be processing the snippet and finding the path. Otherwise I wouldn’t have the aliases, right? I thought you might be on to something when you mention “it’s too late” to affect the 'config' list. – dnugent-psu Jun 5 '14 at 20:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.