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

Running Behat tests throws [error] Drupal is not installed. #4215

Closed
dmgig opened this issue Jul 27, 2020 · 11 comments
Closed

Running Behat tests throws [error] Drupal is not installed. #4215

dmgig opened this issue Jul 27, 2020 · 11 comments
Labels
Support A support request

Comments

@dmgig
Copy link

dmgig commented Jul 27, 2020

I want to run behat tests but I get the error [error] Drupal is not installed.

Drupal does seem to be installed, I can access it at the url on my DDEV environment, and it runs as it should.

The problem seems to be BLT not getting the status info from drush.

Meaning, when I run ddev exec drush status I see the result which looks entirely correct. But when I run blt doctor, the result of its execution of ddev exec drush status is an empty array (I checked this by dumping $status_info in Acquia\Blt\Robo\Inspector::getDrushStatus).

Having gone through each error shown by blt doctor, all seem correct when looking at drush status, settings.php, etc.

Detailed error output

dg@iMac teamleaders (develop) $ blt tests:behat:run
array(0) {
}
PHP Notice:  Undefined index: db-driver in /Users/dg/Repos/teamleaders/vendor/acquia/blt/src/Robo/Inspector/Inspector.php on line 332

Notice: Undefined index: db-driver in /Users/dg/Repos/teamleaders/vendor/acquia/blt/src/Robo/Inspector/Inspector.php on line 332
[error]  Drupal is not installed
For troubleshooting guidance and support, see https://docs.acquia.com/blt/support/

BLT doctor output

You will see some Kint deprecation errors, but I don't think they are related?

dg@iMac teamleaders (develop) $ blt doctor -vvv
[debug] Drupal VM is not initialized.

[Robo\Common\ProcessExecutor] Running /Users/dg/Repos/teamleaders/vendor/bin/drush @self status --format=json --fields=* in /Users/dg/Repos/teamleaders/docroot
<em class="placeholder">Deprecated function</em>: Array and string offset access syntax with curly braces is deprecated in <em class="placeholder">require()</em> (line <em class="placeholder">17</em> of <em class="placeholder">/Users/dg/Repos/teamleaders/docroot/modules/contrib/devel/kint/kint/Kint.class.php</em>). 

{
    "drupal-version": "8.9.2",
    "uri": "https://teamleaders.ddev.site",
    "db-driver": "mysql",
    "db-hostname": "127.0.0.1",
    "db-port": "32787",
    "db-username": "db",
    "db-password": "db",
    "db-name": "db",
    "db-status": "Connected",
    "bootstrap": "Successful",
    "theme": "breeze",
    "admin-theme": "claro",
    "php-bin": "/usr/local/Cellar/php/7.4.7/bin/php",
    "php-conf": {
        "/usr/local/etc/php/7.4/php.ini": "/usr/local/etc/php/7.4/php.ini"
    },
    "php-os": "Darwin",
    "drush-script": "/Users/dg/Repos/teamleaders/vendor/drush/drush/drush",
    "drush-version": "10.3.1",
    "drush-temp": "/tmp",
    "drush-cache-directory": "/Users/dg/.drush/cache",
    "drush-conf": [
        "/Users/dg/Repos/teamleaders/vendor/drush/drush/drush.yml",
        "/Users/dg/Repos/teamleaders/drush/drush.yml",
        "/Users/dg/Repos/teamleaders/docroot/sites/default/local.drush.yml"
    ],
    "drush-alias-files": [
        "/Users/dg/Reposteamleaders/drush/sites/teamleaders.site.yml"
    ],
    "alias-searchpaths": [
        "/Users/dg/Repos/teamleaders/drush/sites"
    ],
    "install-profile": "lightning",
    "root": "/Users/dg/Repos/teamleaders/docroot",
    "drupal-settings-file": "sites/default/settings.php",
    "site": "sites/default",
    "themes": "sites/all/themes",
    "modules": "sites/all/modules",
    "files": "sites/default/files",
    "private": "/Users/dg/Repos/teamleaders/files-private/default",
    "temp": "/tmp",
    "config-sync": "/Users/dg/Repos/teamleaders/config/default",
    "%paths": {
        "%root": "/Users/dg/Repos/teamleaders/docroot",
        "%site": "sites/default",
        "%modules": "sites/all/modules",
        "%themes": "sites/all/themes",
        "%config-sync": "/Users/dg/Repos/teamleaders/config/default",
        "%files": "sites/default/files",
        "%temp": "/tmp",
        "%private": "/Users/dg/Repos/teamleaders/files-private/default"
    },
    "base-profile": ""
}

[NOTE] the followinig line is the dump of $status_info in Acquia\Blt\Robo\Inspector::getDrushStatus [END NOTE]
array(0) {
}
+---------------------------+-----------------------------------------------------------+
| Property                  | Value                                                     |
+---------------------------+-----------------------------------------------------------+
| blt-version               | 11.4.2                                                    |
| composer-version          | Composer version 1.10.0 2020-03-10 14:08:05               |
| root                      | /Users/dg/Repos/teamleaders/docroot |
| stacks.drupal-vm.inited   | false                                                     |
| stacks.dev-desktop.inited | false                                                     |
| uri                       | default                                                   |
+---------------------------+-----------------------------------------------------------+
[debug] Verifying that Drupal is installed...
[Robo\Common\ProcessExecutor] Running /Users/dg/Repos/teamleaders/vendor/bin/drush @self --uri= status bootstrap in /Users/dg/Repos/teamleaders/docroot

[KNIT DEPRECATION ERROR REPEATS]

 Drupal bootstrap : Successful
+------------------------------------------+--------------------------------------------------------------+
| Check                                    | Problem                                                      |
+------------------------------------------+--------------------------------------------------------------+
| BehatCheck:checkBaseUrl:uri              | base_url in tests/behat/local.yml does not match the site    |
|                                          | URI.                                                         |
|                                          |   Behat base_url is set to                                   |
|                                          | https://teamleaders.ddev.site.                               |
|                                          |   Drush site URI is set to default.                          |
| DbCheck:checkRequiredKeys                | drush status is missing the 'db-hostname' key.               |
| DrupalCheck:checkDrupalBootstrapped      | Could not bootstrap Drupal via drush without alias.          |
| DrupalCheck:checkDrupalInstalled         | Drupal is not installed.                                     |
|                                          |                                                              |
|                                          | Run `blt drupal:install` to install Drupal locally.          |
| FileSystemCheck:checkFileSystem:%files   | Public files directory is not set.                           |
| FileSystemCheck:checkFileSystem:%private | Private files directory is not set.                          |
| FileSystemCheck:checkFileSystem:%temp    | Temporary files directory is not set.                        |
| NodeCheck:checkNodeVersionFileExists     | Neither .nvmrc nor .node-version file found in repo root.    |
| PhpCheck:checkPhpDateTimezone            | PHP setting for date.timezone is not set.                    |
|                                          |   Define date.timezone in /usr/local/etc/php/7.4/php.ini     |
| WebUriCheck:checkUri                     | Site URI is not set                                          |
|                                          | Is options.uri set correctly in                              |
|                                          | /Users/dg/Repos/teamleaders/docroot/si |
|                                          | tes/default/local.drush.yml?                                 |
+------------------------------------------+--------------------------------------------------------------+
[error]  BLT Doctor discovered one or more critical issues.
For troubleshooting guidance and support, see https://docs.acquia.com/blt/support/
3.551s total time elapsed.

**System information**
* Operating system type: Mac OSX 
* Operating system version: Mojave
* BLT version: 11.4.2
@dmgig dmgig added the Support A support request label Jul 27, 2020
@mikemadison13
Copy link
Contributor

mikemadison13 commented Jul 27, 2020

Are you by chance running ddev drush status or just drush status? As a general rule you should be running "all" drush and blt commands inside your ddev container (so, ddev drush, ddev blt, etc.)

Also, did you by chance setup your ddev project using @lcatlett's plugin for DDEV + BLT? Highly recommend doing so, it makes a lot of things "just work." -- https://github.com/lcatlett/blt-ddev

@dmgig
Copy link
Author

dmgig commented Jul 28, 2020

Thanks, yes, I should have made that clear, I used ddev exec drush status (this is inside the container, as you mentioned).

I will check out lcatlett's repo, that's great, I wasn't aware of it.

Thanks for the response.

@dmgig
Copy link
Author

dmgig commented Jul 28, 2020

Looking into this a little more - it actually does seem to have to do with the deprecation warning.

When I place error_reporting(0); at the top of the file which is throwing the deprecation error (in this case /Users/dg/Repos/teamleaders/docroot/modules/contrib/devel/kint/kint/Kint.class.php), it is silenced and blt doctor and the behat tests run normally.

It seems like it is the methods listed below which are expecting strings like 'Successful' and 'Drupal bootstrap : Successful'.

Acquia\Blt\Robo\Doctor\DrupalCheck::checkDrupalBootstrapped
Acquia\Blt\Robo\Inspector\Inspector::isDrupalInstalled

Even though everything is bootstrapping successfully, BLT reads the error message string as part of the 'Successful' string and so it thinks it failed.

That's what I've found anyway.

@danepowell
Copy link
Contributor

danepowell commented Jul 30, 2020

@dmgig can you check, what is the exit code of drush @self --uri= status bootstrap when it throws the deprecation error?

BLT checks for the output to be exactly Drupal bootstrap : Successful, I think it would be okay to instead check that the output contains the string Drupal bootstrap : Successful to account for the presence of non-fatal errors.

However it also checks that the exit code is 0, if there's any other exit code then I don't think BLT has any choice but to assume something is wrong. We could make the error message more informative though.

@dmgig
Copy link
Author

dmgig commented Jul 31, 2020

@danepowell when I do ddev exec drush @self --uri= status bootstrap it looks like:

dg@iMac teamleaders (develop) $ ddev exec drush @self --uri= status bootstrap
 Drupal bootstrap : Successful

@danepowell
Copy link
Contributor

Now I'm confused, shouldn't there be an error message there?

When you get the error message, after running the status check, what's the output of echo $?? We need to see that when the status check throws a non-fatal error, the return code is still 0. Otherwise there's not much BLT can do about this, it becomes a Drush issue.

@danepowell danepowell added the Awaiting response Maintainer needs more info label Jul 31, 2020
@dmgig
Copy link
Author

dmgig commented Jul 31, 2020

@danepowell Hey - thanks. I ran the following, with output to show the state of the file. Let me know if it is incorrect.

# file with no changes
head -8 docroot/modules/contrib/devel/kint/kint/Kint.class.php

ddev exec drush @self --uri= status bootstrap

echo $?

blt doctor

echo $?

# set error_reporting(0); 
sed -i '' -e '1s/.*/<?php error_reporting\(0\);/' docroot/modules/contrib/devel/kint/kint/Kint.class.php

head -8 docroot/modules/contrib/devel/kint/kint/Kint.class.php

ddev exec drush @self --uri= status bootstrap

echo $?

blt doctor

echo $?

And the results were (I added a couple of newlines after each output just for my own clarity).

dg@iMac teamleaders (develop) $ # file with no changes


dg@iMac teamleaders (develop) $ head -8 docroot/modules/contrib/devel/kint/kint/Kint.class.php
<?php

/**
 * Kint is a zero-setup debugging tool to output information about variables and stack traces prettily and comfortably.
 *
 * https://github.com/raveren/kint
 */



dg@iMac teamleaders (develop) $ ddev exec drush @self --uri= status bootstrap
 Drupal bootstrap : Successful



dg@iMac teamleaders (develop) $ echo $?
0


dg@iMac teamleaders (develop) $ blt doctor
+---------------------------+-----------------------------------------------------------+
| Property                  | Value                                                     |
+---------------------------+-----------------------------------------------------------+
| blt-version               | 11.4.2                                                    |
| composer-version          | Composer version 1.10.0 2020-03-10 14:08:05               |
| root                      | /Users/dg/Repos/nyc/teamleaders/docroot |
| stacks.drupal-vm.inited   | false                                                     |
| stacks.dev-desktop.inited | false                                                     |
| uri                       | default                                                   |
+---------------------------+-----------------------------------------------------------+
+------------------------------------------+--------------------------------------------------------------+
| Check                                    | Problem                                                      |
+------------------------------------------+--------------------------------------------------------------+
| BehatCheck:checkBaseUrl:uri              | base_url in tests/behat/local.yml does not match the site    |
|                                          | URI.                                                         |
|                                          |   Behat base_url is set to                                   |
|                                          | https://teamleaders.ddev.site.                               |
|                                          |   Drush site URI is set to default.                          |
| DbCheck:checkRequiredKeys                | drush status is missing the 'db-hostname' key.               |
| DrupalCheck:checkDrupalBootstrapped      | Could not bootstrap Drupal via drush without alias.          |
| DrupalCheck:checkDrupalInstalled         | Drupal is not installed.                                     |
|                                          |                                                              |
|                                          | Run `blt drupal:install` to install Drupal locally.          |
| FileSystemCheck:checkFileSystem:%files   | Public files directory is not set.                           |
| FileSystemCheck:checkFileSystem:%private | Private files directory is not set.                          |
| FileSystemCheck:checkFileSystem:%temp    | Temporary files directory is not set.                        |
| NodeCheck:checkNodeVersionFileExists     | Neither .nvmrc nor .node-version file found in repo root.    |
| PhpCheck:checkPhpDateTimezone            | PHP setting for date.timezone is not set.                    |
|                                          |   Define date.timezone in /usr/local/etc/php/7.4/php.ini     |
| SimpleSamlPhpCheck:checkSimpleSamlPhp    | The configuration file: /metadata/saml20-idp-remote.php in   |
|                                          | /Users/dg/Repos/nyc/teamleaders/simplesaml |
|                                          | php does not match the one in                                |
|                                          | /Users/dg/Repos/nyc/teamleaders/vendor/sim |
|                                          | plesamlphp/simplesamlphp.                                    |
|                                          |   Run `blt source:build:simplesamlphp-config` to copy the    |
|                                          | files from the repo root to the library.                     |
| WebUriCheck:checkUri                     | Site URI is not set                                          |
|                                          | Is options.uri set correctly in                              |
|                                          | /Users/dg/Repos/nyc/teamleaders/docroot/si |
|                                          | tes/default/local.drush.yml?                                 |
+------------------------------------------+--------------------------------------------------------------+
[error]  BLT Doctor discovered one or more critical issues.
For troubleshooting guidance and support, see https://docs.acquia.com/blt/support/


dg@iMac teamleaders (develop) $ echo $?
1


dg@iMac teamleaders (develop) $ # set error_reporting(0);


dg@iMac teamleaders (develop) $ sed -i '' -e '1s/.*/<?php error_reporting\(0\);/' docroot/modules/contrib/devel/kint/kint/Kint.class.php


dg@iMac teamleaders (develop) $ head -8 docroot/modules/contrib/devel/kint/kint/Kint.class.php
<?php error_reporting(0);

/**
 * Kint is a zero-setup debugging tool to output information about variables and stack traces prettily and comfortably.
 *
 * https://github.com/raveren/kint
 */



dg@iMac teamleaders (develop) $ ddev exec drush @self --uri= status bootstrap
 Drupal bootstrap : Successful



dg@iMac teamleaders (develop) $ echo $?
0


dg@iMac teamleaders (develop) $ blt doctor
+---------------------------+--------------------------------------------------------------+
| Property                  | Value                                                        |
+---------------------------+--------------------------------------------------------------+
| %paths.%root              | /Users/dg/Repos/nyc/teamleaders/docroot    |
| %paths.%site              | sites/default                                                |
| %paths.%modules           | sites/all/modules                                            |
| %paths.%themes            | sites/all/themes                                             |
| %paths.%config-sync       | /Users/dg/Repos/nyc/teamleaders/config/def |
|                           | ault                                                         |
| %paths.%files             | sites/default/files                                          |
| %paths.%temp              | /tmp                                                         |
| %paths.%private           | /Users/dg/Repos/nyc/teamleaders/files-priv |
|                           | ate/default                                                  |
| admin-theme               | claro                                                        |
| alias-searchpaths.0       | /Users/dg/Repos/nyc/teamleaders/drush/site |
|                           | s                                                            |
| base-profile              |                                                              |
| blt-version               | 11.4.2                                                       |
| bootstrap                 | Successful                                                   |
| composer-version          | Composer version 1.10.0 2020-03-10 14:08:05                  |
| config-sync               | /Users/dg/Repos/nyc/teamleaders/config/def |
|                           | ault                                                         |
| db-driver                 | mysql                                                        |
| db-hostname               | 127.0.0.1                                                    |
| db-name                   | db                                                           |
| db-password               | db                                                           |
| db-port                   | 32826                                                        |
| db-status                 | Connected                                                    |
| db-username               | db                                                           |
| drupal-settings-file      | sites/default/settings.php                                   |
| drupal-version            | 8.9.2                                                        |
| drush-alias-files.0       | /Users/dg/Repos/nyc/teamleaders/drush/site |
|                           | s/teamleaders.site.yml                                       |
| drush-cache-directory     | /Users/dg/.drush/cache                              |
| drush-conf.0              | /Users/dg/Repos/nyc/teamleaders/vendor/dru |
|                           | sh/drush/drush.yml                                           |
| drush-conf.1              | /Users/dg/Repos/nyc/teamleaders/drush/drus |
|                           | h.yml                                                        |
| drush-conf.2              | /Users/dg/Repos/nyc/teamleaders/docroot/si |
|                           | tes/default/local.drush.yml                                  |
| drush-script              | /Users/dg/Repos/nyc/teamleaders/vendor/dru |
|                           | sh/drush/drush                                               |
| drush-temp                | /tmp                                                         |
| drush-version             | 10.3.1                                                       |
| files                     | sites/default/files                                          |
| install-profile           | lightning                                                    |
| modules                   | sites/all/modules                                            |
| php-bin                   | /usr/local/Cellar/php/7.4.7/bin/php                          |
| php-conf.0                | /usr/local/etc/php/7.4/php.ini                               |
| php-os                    | Darwin                                                       |
| private                   | /Users/dg/Repos/nyc/teamleaders/files-priv |
|                           | ate/default                                                  |
| root                      | /Users/dg/Repos/nyc/teamleaders/docroot    |
| site                      | sites/default                                                |
| stacks.drupal-vm.inited   | false                                                        |
| stacks.dev-desktop.inited | false                                                        |
| temp                      | /tmp                                                         |
| theme                     | breeze                                                       |
| themes                    | sites/all/themes                                             |
| uri                       | https://teamleaders.ddev.site                                |
+---------------------------+--------------------------------------------------------------+
+---------------------------------------+--------------------------------------------------------------+
| Check                                 | Problem                                                      |
+---------------------------------------+--------------------------------------------------------------+
| NodeCheck:checkNodeVersionFileExists  | Neither .nvmrc nor .node-version file found in repo root.    |
| PhpCheck:checkPhpDateTimezone         | PHP setting for date.timezone is not set.                    |
|                                       |   Define date.timezone in /usr/local/etc/php/7.4/php.ini     |
| SimpleSamlPhpCheck:checkSimpleSamlPhp | The configuration file: /metadata/saml20-idp-remote.php in   |
|                                       | /Users/dg/Repos/nyc/teamleaders/simplesaml |
|                                       | php does not match the one in                                |
|                                       | /Users/dg/Repos/nyc/teamleaders/vendor/sim |
|                                       | plesamlphp/simplesamlphp.                                    |
|                                       |   Run `blt source:build:simplesamlphp-config` to copy the    |
|                                       | files from the repo root to the library.                     |
+---------------------------------------+--------------------------------------------------------------+
[error]  BLT Doctor discovered one or more critical issues.
For troubleshooting guidance and support, see https://docs.acquia.com/blt/support/


dg@iMac teamleaders (develop) $ echo $?
1

@no-response no-response bot removed the Awaiting response Maintainer needs more info label Jul 31, 2020
@dmgig
Copy link
Author

dmgig commented Jul 31, 2020

Can rerun with -vvv if needed.

@danepowell
Copy link
Contributor

danepowell commented Jul 31, 2020

In your original post you said that the command drush @self --uri= status bootstrap produced output such as:

[KNIT DEPRECATION ERROR REPEATS]

 Drupal bootstrap : Successful

Can you reproduce that now? If so, that's where I need to see the output of echo $? afterwards. I need to see if the Drush command returns exit code 0 when there's a deprecation error. In all of the later examples you posted, there's no errors in the Drush command output, so it's no surprise that they return 0.

@dmgig
Copy link
Author

dmgig commented Aug 1, 2020

Let's see -

My original post doesn't use drush @self --uri= status bootstrap, that was a command you provided.

My post showed that, when error_reporting is on, and I run BLT commands (like blt tests:behat:run or blt doctor) the command fails.

When error reporting is on, the deprecation string prints to the terminal when I run blt tests:behat:run -vvv. If I run it without -vvv the deprecation notice is not printed to the terminal - but the result is the same: it fails and in the same way. Just in the background.

When I run drush @self --uri= status bootstrap or even drush @self --uri= status bootstrap -vvv, there is no difference whether error reporting is turned on or off. The result is always Drupal bootstrap : Successful and echo $? returns 0 in both cases.

BLT seems to be loading that Kint class as part of its bootstrap process, where as Drush alone does not.

@dmgig
Copy link
Author

dmgig commented Aug 10, 2020

Thanks @danepowell

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

No branches or pull requests

3 participants