Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Install multisite on fresh D8 fail if DRUPAL/sites/sites.php does't exist #1686

Closed
GuilleW opened this issue Oct 14, 2015 · 9 comments
Closed

Comments

@GuilleW
Copy link

GuilleW commented Oct 14, 2015

Hello,

I try to install D8 from drush on Debian server, it fails with "Unable to find a matching SQL Class". However, it's not the real issue.

Drush 8 installation:

composer global require drush/drush:8.0.0-rc1

OK

Drupal 8 installation:

drush dl drupal-8-dev --yes --destination=/var/www --drupal-project-rename=drupal-8.x

OK

Install website

I create folder "DRUPAL/sites/d8.domain.tld" with a working settings.php (got it from previous D8 install with interface)
Now, i try to install a multisite website:

drush --root=/var/www/drupal-8.x --uri=d8.domain.tld -y si

ERROR

exception 'Drush\Sql\SqlException' with message 'Unable to find a matching SQL Class. Drush cannot find your database connection details.' in /root/.composer/vendor/drush/drush/commands/sql/sql.drush.inc:597      [error]
Stack trace:
#0 /root/.composer/vendor/drush/drush/commands/core/site_install.drush.inc(107): drush_sql_get_class()
#1 [internal function]: drush_core_pre_site_install()
#2 /root/.composer/vendor/drush/drush/includes/command.inc(364): call_user_func_array('drush_core_pre_...', Array)
#3 /root/.composer/vendor/drush/drush/includes/command.inc(215): _drush_invoke_hooks(Array, Array)
#4 [internal function]: drush_command()
#5 /root/.composer/vendor/drush/drush/includes/command.inc(183): call_user_func_array('drush_command', Array)
#6 /root/.composer/vendor/drush/drush/lib/Drush/Boot/BaseBoot.php(62): drush_dispatch(Array)
#7 /root/.composer/vendor/drush/drush/drush.php(70): Drush\Boot\BaseBoot->bootstrap_and_dispatch()
#8 /root/.composer/vendor/drush/drush/drush.php(11): drush_main()
#9 {main}

FIX

Create an empty files "sites.php" in "DRUPAL/sites/"
Now it works !
Nothing about SQL...

I know Drupal 8 creates this file when using web interface install (with comments inside).
Can Drush creates this file on site install...?

@weitzman
Copy link
Member

We already create a sites.php in drush_core_pre_site_install(). Perhaps you can debug and see why it is not working for you.

@GuilleW
Copy link
Author

GuilleW commented Oct 14, 2015

We already create a sites.php in drush_core_pre_site_install()

Indeed, but sites.php is created later.
The problem occurs at the first line inside this function: drush_sql_get_class()

function drush_core_pre_site_install($profile = NULL) {
  $sql = drush_sql_get_class();

These commands work:

drush --root=/var/www/drupal-8.x --uri=d8.domain.tld -y si --db-url=mysql://root:pass@localhost:port/dbname
# with empty sites/sites.php and sites/d8.domain.tld/settings.php with correct MySQL driver
drush --root=/var/www/drupal-8.x --uri=d8.domain.tld -y si 

If I remove sites/sites.php and run

# with sites/d8.domain.tld/settings.php with correct MySQL driver
drush --root=/var/www/drupal-8.x --uri=d8.domain.tld -y si 

I got exception in first post.

Digging...

@GuilleW
Copy link
Author

GuilleW commented Oct 14, 2015

I found that:

/var/www/drupal-8.x/core/lib/Drupal/Core/Database/Database.php(271): self::$databaseInfo  <<<---- [[[ IS EMPTY ]]]
/root/.composer/vendor/drush/drush/lib/Drush/Sql/Sql8.php(12): Database::getConnectionInfo($database)
/root/.composer/vendor/drush/drush/commands/sql/sql.drush.inc(591): $sqlVersion->get_db_spec()
/root/.composer/vendor/drush/drush/commands/core/site_install.drush.inc(107): drush_sql_get_class()

The problem is not in Drush itself...
For some reason Drupal/Core/Database/Database.php doesn't load my settings.php if sites/sites.php doesn't exist (I stopped digging here, so I don't know why).

@GuilleW
Copy link
Author

GuilleW commented Oct 14, 2015

I just move $sitesfile and add a touch(), and it works.

function drush_core_pre_site_install($profile = NULL) {
  $sitesfile = "sites/sites.php";
  touch($sitesfile);
  $sql = drush_sql_get_class();

@weitzman
Copy link
Member

We dont want unconditionally create a sitesfile like that. By copying settings.php, you did half of a manual install of your site. The ogther half is sites.php. You need to do none or both. sites.php is a new requirement for Drupal 8 when using Drupal's multisite feature.

@drzraf
Copy link

drzraf commented Dec 7, 2016

I'm getting the exact the same behaviour as OP
At the very least, --debug should give information about which directory drush_conf_path() is iterate before failing-back on the default
The sites.php requirements is hard to find and is not verified in an explicit enough manner.

@weitzman
Copy link
Member

weitzman commented Dec 7, 2016

--debug does say what site_path is in use, as does drush status. Can be hard to miss in the noise of --debug.

@drzraf
Copy link

drzraf commented Dec 8, 2016

Yes it does as:

Initialized Drupal site blahfoobar at sites/default [0.13 sec, 9.32 MB]

But when such a message arises, it's pretty hard to understand why it chose "default" rather than "sites/blahfoobar".

  • Was "blahfoobar" unreadable?
  • Was "blahfoobar/settings.php" unreadable?
  • Was "blahfoobar/settings.php" not containing a correct $db definition?
  • Was the (D8-mandatory)"sites.php" absent?

Having drush_conf_path() showing how it iterates over its recognized possibility could help tracking down such an issue.

@weitzman
Copy link
Member

PRs welcome on this..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants