I've a multi-site installation that don't have any 'sites/default/settings.php' file, instead I have 'sites/site1.com/settings.php', 'sites/site2.com/settings.php', etc. Trying to use the '@sites' alias (e.g. for a pm-update) always fails with something like:

Could not find a Drupal settings.php file at                         [error]
./sites/default/settings.php.
The drush command '@sites pm-update' could not be found.             [error]

Could drush not strictly depend to 'sites/default/settings.php' in multi-site installations?

As a workaround I've created an empty 'sites/default/settings.php' file (with a simple touch command), and this seems to let drush working; but I'm not sure that this is a safe workaround, can someone confirm?

Comments

greg.1.anderson’s picture

Category: bug » support
Status: Active » Fixed

Make sure that you have correctly set your --root before you use @sites, or use the conjoined format: /path/to/drupal/@sites.

Re-open if you've done that and it's still not working.

Edit 18 June: Fixed a typo above; was missing a '/'.

Kafu’s picture

Status: Fixed » Active

Hi Greg,

I've removed the empty 'sites/default/settings.php' file and I've tried your suggestion (trying different syntaxes, as I'm not sure what one to use), but the results are:

$ ../../drush/drush -r /usr/local/home/daniele/drupal/drupal2/drupal@sites updatedb
The directory /usr/local/home/daniele/drupal/drupal2/drupal@sites    [error]
does not contain a valid Drupal installation
Command updatedb needs a higher bootstrap level to run - you will    [error]
need invoke drush from a more functional Drupal environment to run
this command.
The drush command 'updatedb' could not be executed.                  [error]
$ ../../drush/drush /usr/local/home/daniele/drupal/drupal2/drupal@sites updatedb
The directory /usr/local/home/daniele/drupal/drupal2/drupal@sites    [error]
does not contain a valid Drupal installation
Command updatedb needs a higher bootstrap level to run - you will    [error]
need invoke drush from a more functional Drupal environment to run
this command.
The drush command 'updatedb' could not be executed.                  [error]
$ ../../drush/drush -r /usr/local/home/daniele/drupal/drupal2/drupal @sites updatedb
Could not find a Drupal settings.php file at                         [error]
./sites/default/settings.php.
The drush command '@sites updatedb' could not be found.              [error]

I've tried running the commands both from the drupal installation directory (/usr/local/home/daniele/drupal/drupal2/drupal) that from the drush installation directory. Same results.

greg.1.anderson’s picture

Status: Active » Postponed (maintainer needs more info)

If you can say drush -r path -l mysite1.com status and drush -r path -l mysite2.com status, then you should also be able to say drush -r path @sites or drush path/@sites to use the @sites alias. (Sorry for the typo in #2 above).

The 'path' you use should be the path to the folder that contains your drupal folder; this path should point to the location that holds sites/mysite1.com/settings.php, etc.

The error "Could not find a Drupal settings.php file at ./sites/default/settings.php" means that drush could not bootstrap your site; if no site is specified, it tries 'default' before failing. Perhaps your path in -r is not pointing at the right location?

Kafu’s picture

The path is strange but is right. The problem is when using the --root/-r argument with @sites alias:

$ ../../drush/drush -r /usr/local/home/daniele/drupal/drupal2/drupal -l localsite1.com status
 Drupal version         :  6.17
 Site URI               :  localsite1.com
 Database driver        :  pgsql
 Database hostname      :  127.0.0.1
 Database username      :  drupal
 Database name          :  drupal2
 Database               :  Connected
 Drupal bootstrap       :  Successful
 Drupal user            :  Anonymous
 Default theme          :  zen
 Administration theme   :  garland
 PHP configuration      :  /etc/php5/cli/php.ini
 Drush version          :  All-versions-3.0
 Drush configuration    :
 Drupal root            :  /usr/local/home/daniele/drupal/drupal2/drupal
 Site path              :  sites/localsite1.com
 File directory path    :  sites/localsite1.com/files
$ ../../drush/drush -r /usr/local/home/daniele/drupal/drupal2/drupal -l localsite2.com status
 Drupal version         :  6.17                                          
 Site URI               :  localsite2.com                                
 Database driver        :  pgsql                                         
 Database hostname      :  127.0.0.1                                     
 Database username      :  drupal                                        
 Database name          :  drupal2_it                                    
 Database               :  Connected                                     
 Drupal bootstrap       :  Successful                                    
 Drupal user            :  Anonimo                                       
 Default theme          :  zen                                      
 Administration theme   :  garland                                       
 PHP configuration      :  /etc/php5/cli/php.ini                         
 Drush version          :  All-versions-3.0                              
 Drush configuration    :                                                
 Drupal root            :  /usr/local/home/daniele/drupal/drupal2/drupal 
 Site path              :  sites/localsite2.com                          
 File directory path    :  sites/localsite2.com/files                    
$ ../../drush/drush /usr/local/home/daniele/drupal/drupal2/drupal/@sites status
You are about to execute 'status' on all of the following targets:
  /usr/local/home/daniele/drupal/drupal2/drupal#localsite2.com
  /usr/local/home/daniele/drupal/drupal2/drupal#localsite1.com
Continue?  (y/n): y
 Drupal version         :  6.17                                          
 Site URI               :  localsite2.com                                
 Database driver        :  pgsql                                         
 Database hostname      :  127.0.0.1                                     
 Database username      :  drupal                                        
 Database name          :  drupal2_it                                    
 Database               :  Connected                                     
 Drupal bootstrap       :  Successful                                    
 Drupal user            :  Anonimo                                       
 Default theme          :  zen                                      
 Administration theme   :  garland                                       
 PHP configuration      :  /etc/php5/cli/php.ini                         
 Drush version          :  All-versions-3.0                              
 Drush configuration    :                                                
 Drupal root            :  /usr/local/home/daniele/drupal/drupal2/drupal 
 Site path              :  sites/localsite2.com                          
 File directory path    :  sites/localsite2.com/files                    

 Drupal version         :  6.17                                          
 Site URI               :  localsite1.com                                
 Database driver        :  pgsql                                         
 Database hostname      :  127.0.0.1                                     
 Database username      :  drupal                                        
 Database name          :  drupal2                                       
 Database               :  Connected                                     
 Drupal bootstrap       :  Successful                                    
 Drupal user            :  Anonymous                                     
 Default theme          :  zen                                      
 Administration theme   :  garland                                       
 PHP configuration      :  /etc/php5/cli/php.ini                         
 Drush version          :  All-versions-3.0                              
 Drush configuration    :                                                
 Drupal root            :  /usr/local/home/daniele/drupal/drupal2/drupal 
 Site path              :  sites/localsite1.com                          
 File directory path    :  sites/localsite1.com/files                    

But:

$ ../../drush/drush -r /usr/local/home/daniele/drupal/drupal2/drupal @sites status
Could not find a Drupal settings.php file at                         [error]
./sites/default/settings.php.
The drush command '@sites status' could not be found.                [error]

I've also noted that output is not always produced when using @sites alias, e.g.:

$ ../../drush/drush -r /usr/local/home/daniele/drupal/drupal2/drupal -l localsite1.com cache-clear all
'all' cache was cleared                                              [success]

but:

$ ../../drush/drush /usr/local/home/daniele/drupal/drupal2/drupal/@sites cache-clear all
You are about to execute 'cache-clear all' on all of the following targets:
  /usr/local/home/daniele/drupal/drupal2/drupal#localsite2.com
  /usr/local/home/daniele/drupal/drupal2/drupal#localsite1.com
Continue?  (y/n): y
 
 

Two empty lines are written after the confirmation.

This is not important for 'cache-clear', but does 'update' (or other important commands) writes out all the output?

greg.1.anderson’s picture

Title: '@sites' alias not working in multi-sites without 'sites/default/settings.php' » '@sites' alias doesn't work unless drush can find at least one local site at the drupal root
Status: Postponed (maintainer needs more info) » Active

Yep, this is a bug. Per #4 above:

../../drush/drush -r /usr/local/home/daniele/drupal/drupal2/drupal @sites status Does not work

If you add -l -l localsite2.com to the above, then it works again. The problem is that drush tries to bootstrap a site before it processes the @sites alias, so if -l is not set and there is no site in 'default', then @sites will fail when it should succeed.

(@Kafu: The last thing you mention, where messages and --pipe options are not correctly merged and output with site lists, is a duplicate of an existing issue.)

greg.1.anderson’s picture

Assigned: Unassigned » greg.1.anderson
greg.1.anderson’s picture

Status: Active » Fixed

Fixed.

greg.1.anderson’s picture

Category: support » bug
Status: Fixed » Patch (to be ported)

Recommended for 3.x.

--- includes/sitealias.inc 2 Aug 2010 14:16:23 -0000 1.48
+++ includes/sitealias.inc 4 Aug 2010 06:04:08 -0000
@@ -392,6 +392,9 @@ function _drush_sitealias_find_and_load_
}
else {
$drupal_root = drush_get_context('DRUSH_DRUPAL_ROOT');
+ if ($drupal_root == NULL) {
+ $drupal_root = drush_get_option(array('r', 'root'), drush_locate_root());
+ }
}
if (isset($drupal_root) && !is_array($drupal_root)) {
drush_sitealias_create_sites_alias($drupal_root);

greg.1.anderson’s picture

Priority: Normal » Critical
moshe weitzman’s picture

Status: Patch (to be ported) » Fixed

Committed to 6--3 since it is critical and we need to roll a release.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.