My set-up:

- wimleers.com (my own site) on localhost
- on filesystem at /htdocs/wimleers.com
- through web server available at http://dev/wimleers.com
- sites.php file with the following contents:

$sites['dev'] = 'wimleers.com';
$sites['localhost'] = 'wimleers.com';

(Using dev.wimleers.com instead of dev doesn't help. This is a very strange syntax, by the way.)
- *no* sites/default directory, only a sites/wimleers.com directory (and of course sites/all)

Drush error message:

--( /htdocs/wimleers.com/sites )-- drush cc
Command cache-clear needs a higher bootstrap level to run - you will need invoke drush from a more functional Drupal       [error]
environment to run this command.
The drush command 'cc' could not be executed.                                                                              [error]
Could not find a Drupal settings.php file at ./sites/default/settings.php. 

Possibly related to #443576: drush_site_path() unaware of sites.php on D7 and/or #399474: drush fails when using a domain with sites.php.

Comments

moshe weitzman’s picture

what is the name of the subdir under sites that holds settings.php? is it wimleers.com?

could you add another line to sites.php like $sites['default'] = 'wimleers.com';

wim leers’s picture

what is the name of the subdir under sites that holds settings.php? is it wimleers.com?

Correct.

could you add another line to sites.php like $sites['default'] = 'wimleers.com';

That worked. However, uncommenting the line again doesn't allow me to reproduce the problem above. While it used to be perfectly reproducible, even when starting a new terminal session. Does drush cache things? If not, I don't know how to explain this.

Also: I guess I misinterpreted how to fill the $sites array in sites.php? It isn't based on the actual domain name in use; rather, it's based on the directory name inside the Drupal sites directory, and maps that to another directory. That makes sense. So I can actually just replace the contents listed in my first post with what you told me to try, and it'll have the same effect (in my set-up, at least).
(This also explains why localhost.example is used for localhost/example.)

Feeling stupid.

wim leers’s picture

Okay, no, I interpreted it correctly.

Just this:

$sites['default'] = 'wimleers.com';

results in http://dev/wimleers.com showing me the Drupal installation page — meaning that it didn't load sites/wimleers.com. I really do need

$sites['dev'] = 'wimleers.com';

But then it makes even less sense that adding the line you suggested fixed things. Or maybe it just somehow fixes things for Drush. After all, drush doesn't know from which domain name a request is being made, and thus which sites/%site%/settings.php to load. Right? Hence the default. Drush probably does some caching, then, which would explain my inability to reproduce the problem.

greg.1.anderson’s picture

drush cc drush clears the drush command cache. Didn't check to see if that was related to your issue above, though.

greg.1.anderson’s picture

Version: 7.x-4.5 » 8.x-6.x-dev
Status: Active » Closed (won't fix)
Issue tags: +Needs migration

This issue was marked closed (won't fix) because Drush has moved to Github.

If desired, you may copy this bug to our Github project and then post a link here to the new issue. Please also change the status of this issue to closed (duplicate).

Please ask support questions on Drupal Answers.