Score:0

drush not finding correct multisite settings.php

in flag

I have a Drupal 9 site using multisite to support both local and production hosts. I have defined them in sites/sites.php:

$sites['www.electronovelty.com'] = 'www.electronovelty.com';
$sites['www.en9-local.pglatz.com'] = 'www.en9-local.pglatz.com';

and created settings files in

sites/www.electronovelty.com/settings.php
sites/www.en9-local.pglatz.com/settings.php

Using xdebug, I've verified when opening the two web sites that the correct settings.php is used. But when I try to run drush 11, it is using settings from sites/default/settings.php for some reason:

% drush cr -v                            
 [info] Starting bootstrap to site
 [info] Drush bootstrap phase 2
 [info] Try to validate bootstrap phase 2
 [info] Try to validate bootstrap phase 2
 [info] Try to bootstrap at phase 2
 [info] Drush bootstrap phase: bootstrapDrupalRoot()
 [info] Change working directory to /Users/pglatz/dev/electronovelty/en9-www/web
 [info] Initialized Drupal 9.3.12 root directory at /Users/pglatz/dev/electronovelty/en9-www/web
 [info] Try to validate bootstrap phase 2
 [info] Try to bootstrap at phase 2
 [info] Drush bootstrap phase: bootstrapDrupalSite()
 [info] Initialized Drupal site default at sites/default
 [success] Cache rebuild complete.

I tried specifying the uri, and it finds the correct settings.php, but I'm also getting a "command nt found" error, which I do not understand:

% drush -l www.en9-local.pglatz.com -v cr
 [info] Starting bootstrap to site
 [info] Drush bootstrap phase 2
 [info] Try to validate bootstrap phase 2
 [info] Try to validate bootstrap phase 2
 [info] Try to bootstrap at phase 2
 [info] Drush bootstrap phase: bootstrapDrupalRoot()
 [info] Change working directory to /Users/pglatz/dev/electronovelty/en9-www/web
 [info] Initialized Drupal 9.3.12 root directory at /Users/pglatz/dev/electronovelty/en9-www/web
 [info] Try to validate bootstrap phase 2
 [info] Try to bootstrap at phase 2
 [info] Drush bootstrap phase: bootstrapDrupalSite()
 [info] Initialized Drupal site www.en9-local.pglatz.com at sites/www.en9-local.pglatz.com
sh: ^www.en9-local.pglatz.com$: command not found
 [success] Cache rebuild complete.

Where is that error coming from, and what does it mean?

cn flag
Could be a shell expansion issue - try putting the URL in quotes
id flag
+1 you have to escape or quote certain characters in certain shells, notably '-'.
pglatz avatar
in flag
Thanks for the suggestions. I tried double and single quotes on the url in the command line, also tried escaping the - but have the same issue. Also tried --uri= instead of -w. So this is a shell issue, from the command line, rather than something internal to drush? I'm own a Mac, using zsh, but I get a similar error on my remote using ubuntu and bash.
Score:0
de flag

You have two options to handle this:

  1. Use the -l flag with your drush command: drush -l www.electronovelty.com cr

  2. Create a drush alias, and call the alias. To create aliases, you can create the file /drush/sites/self.site/yml, and put the following contents:

     site1:
       uri: www.en9-local.pglatz.com
     site2:
       uri: www.electronovelty.com
    

    You can then use the aliases:

     drush @site1 cr
     drush @site2 cr
    

    And the relevant multisite will be called.

pglatz avatar
in flag
Thanks. I did try `-l `in my second example. I just created a site alias and am still getting the `sh: ^www.en9-local.pglatz.com$: command not found` warning.
Jaypan avatar
de flag
Seems weird that you are getting a shell error for a drush command. Are you running this in a shell script?
Jaypan avatar
de flag
Anyways, if you are getting this error, it means you've introduced a bug somewhere into your system with some contributed or custom code. The suggestions I gave work in a default Drupal mutlisite with Drush 11, so if you are getting an error, it's specific to your system.
pglatz avatar
in flag
thanks, I'll investigate some more
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.