0

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?

3
  • 1
    Could be a shell expansion issue - try putting the URL in quotes
    – Clive
    May 9 at 18:23
  • +1 you have to escape or quote certain characters in certain shells, notably '-'.
    – cilefen
    May 9 at 18:54
  • 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.
    – pglatz
    May 9 at 19:10

1 Answer 1

0

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.

4
  • 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.
    – pglatz
    May 9 at 19:43
  • Seems weird that you are getting a shell error for a drush command. Are you running this in a shell script?
    – Jaypan
    May 9 at 20:11
  • 1
    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.
    – Jaypan
    May 9 at 20:14
  • thanks, I'll investigate some more
    – pglatz
    May 9 at 21:48

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.