0

I'm using Drupal 9 and Drush 11. I have two hosts, one for local testing (www.en9-local.pglatz.com) and a remote production server (www.electronovelty.com).

When I run drush status from either of these hosts, I see Site path is set to sites/default. How do I tell drush which settings.php to use? I tried using the uri argument on the command line; it does find the proper site path, but is also giving an error:

% drush status --uri=www.electronovelty.com
sh: 1: ^www.en9-local.pglatz.com$: not found
sh: 1: ^www.electronovelty.com$: not found
...

Ideally, it wouldn't involve editing files on the remote host, but set with a cmd line argument, env variable, or other setting outside the Drupal installation.

9
  • I don't understand the question. Is this a multi-site? After you configured site aliases for Drush, you move into your local project dir and execute drush cr to clear your local site's cache and drush @myalias cr to clear your remote site's cache. If this is not a multi-site, settings.php always resides in sites/default dir. If this is a multi-site and you have another settings.php in sites/subsite dir for example, execute drush cr -l subsite to execute your local subsite's instance cache.
    – leymannx
    Apr 12 at 13:04
  • Maybe you are confused that Drush is not installed globally anymore? Drush nowadays only supports one install method: As a local dependency of a Composer-based site. However, you can easily write your own Shell alias to achieve what you want, receiving some argument to then take that and cd into the right local directory before executing a Drush command there, and maybe a second argument for the corresponding remote alias. And I think Drush still takes the --root option to point to a certain dir on your local, doesn't it?
    – leymannx
    Apr 12 at 19:00
  • That's -l then. drush cr -l www.en9-local.pglatz.com and drush cr -l www.electronovelty.com. (Although I'm not sure if this setup is a good idea in general.)
    – leymannx
    Apr 12 at 21:17
  • The problem I have is the site has a local and production version. I use the same codebase on both, and a settings file under sites for each, to point to the correct database (sites/www.en9-local.pglatz.com/settings.php, sites/www.electronovelty.com/settings.php). The sites run fine, but drush always uses sites/default/settings.php and I need a way to tell drush which settings file to use. Adding --uri to the drush command line results in the sh: errors above, as does using a site alias. I don't run drush on the remote site from my local, but do run it from the remote site itself.
    – pglatz
    Apr 12 at 21:20
  • Telling you this the third time now 😅 ---> Use -l. Like drush cr -l www.en9-local.pglatz.com.
    – leymannx
    Apr 12 at 21:38

0

Your Answer

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

Browse other questions tagged or ask your own question.