Bootstrap failing with Drush 9.1.0
-
16-01-2021 - |
Question
I had Drush 9 working before it got upgraded to 9.1.0 and am a little bit at my wits end why Bootstrap is failing and why I get "Bootstrap failed" or "! [NOTE] Drupal root not found. Pass --root or a @siteAlias in order to see Drupal-specific commands."
- My build directory is separate from my vendor directory. (shorthanded below to
[build]
and[composer]
) - There are a couple of debugged commands below, one trying to use an alias, and one just using the help command.
- There are a couple extra alias paths (the last two) which are not valid and I can't figure out where they come from (they are not in my
drush.yml
anywhere), but my alias file is found...@default.dev
does seem to work. - adding
-r
or-uri
(or using that in place of the alias) does not make any difference... I still get the Bootstrap failed.
What has changed from earlier versions of Drush 9, or what am I doing incorrectly here? There was similar things with Drush 8 at some point, but none of the solutions that I saw in there worked, and I didn't see anything specific to Drush 9.
[794e@794elmp01 htdocs]$ drush @default.dev cr -d
[preflight] Config paths: /../.drush/drush.yml,/var/..[composer]/vendor/drush/drush/drush.yml
[preflight] Alias paths: /../.drush/sites,/var/..[build]/sites,/var/..[build]/drush/sites,/var/..[composer]/drush/sites
[preflight] Commandfile search paths: /var/../vendor/drush/drush/src
[bootstrap] Bootstrap to site [0.2 sec, 10.19 MB]
[Exception]
Bootstrap failed.
Exception trace:
() at /var/..[composer]/vendor/drush/drush/src/Boot/BootstrapHook.php:31
Drush\Boot\BootstrapHook->initialize() at /var/..[composer]/vendor/consolidation/annotated-command/src/Hooks/Dispatchers/InitializeHookDispatcher.php:34
Consolidation\AnnotatedCommand\Hooks\Dispatchers\InitializeHookDispatcher->callInitializeHook() at /var/..[composer]/vendor/consolidation/annotated-command/src/Hooks/Dispatchers/InitializeHookDispatcher.php:27
Consolidation\AnnotatedCommand\Hooks\Dispatchers\InitializeHookDispatcher->initialize() at /var/..[composer]/vendor/consolidation/annotated-command/src/CommandProcessor.php:117
Consolidation\AnnotatedCommand\CommandProcessor->initializeHook() at /var/..[composer]/vendor/consolidation/annotated-command/src/AnnotatedCommand.php:391
Consolidation\AnnotatedCommand\AnnotatedCommand->initialize() at /var/..[composer]/vendor/symfony/console/Command/Command.php:229
Symfony\Component\Console\Command\Command->run() at /var/..[composer]/vendor/symfony/console/Application.php:859
Symfony\Component\Console\Application->doRunCommand() at /var/..[composer]/vendor/symfony/console/Application.php:206
Symfony\Component\Console\Application->doRun() at /var/..[composer]/vendor/symfony/console/Application.php:125
Symfony\Component\Console\Application->run() at /var/..[composer]/vendor/drush/drush/src/Runtime/Runtime.php:112
Drush\Runtime\Runtime->doRun() at /var/..[composer]/vendor/drush/drush/src/Runtime/Runtime.php:41
Drush\Runtime\Runtime->run() at /var/..[composer]/vendor/drush/drush/drush.php:64
require() at /var/..[composer]/vendor/drush/drush/drush:4
drush list -d
[preflight] Config paths: /home/../.drush/drush.yml,/var/..[composer]/vendor/drush/drush/drush.yml
[preflight] Alias paths: /home/../.drush/sites,/var/..[build]/sites,/var/..[build]/drush/sites,/var/..[composer]/drush/sites
[preflight] Commandfile search paths: /var/..[composer]/vendor/drush/drush/src
[bootstrap] Bootstrap to max [0.22 sec, 10.14 MB]
[debug] Trying to bootstrap as far as we can [0.22 sec, 10.15 MB]
Drush Commandline Tool 9.1.0
! [NOTE] Drupal root not found. Pass --root or a @siteAlias in order to see Drupal-specific commands.
Also, additional info: this is the site reference in the default.site.yml
:
dev:
root: /var/..[build]/htdocs
uri: http://dev.our.internal.url.com
I verified that the root and URI were correct, and that the URI was accessible from the server (it is not a public URI).
EDIT: Adding Drush Status (per request)
drush status -d
[preflight] Config paths: /home/../.drush/drush.yml,/var/[composer]/vendor/drush/drush/drush.yml
[preflight] Alias paths: /home/../.drush/sites,/var/[build]/sites,/var/[build]/sites,/var/[composer]/drush/sites
[preflight] Commandfile search paths: /var/[composer[/vendor/drush/drush/src
[bootstrap] Bootstrap to max [0.19 sec, 10.14 MB]
[debug] Trying to bootstrap as far as we can [0.19 sec, 10.15 MB]
PHP binary : /usr/bin/php
PHP config : /etc/php.ini
PHP OS : Linux
Drush script : /var/[composer]/vendor/bin/drush
Drush version : 9.1.0
Drush temp : /tmp
Drush configs : /home/../.drush/drush.yml
/var/[composer]/vendor/drush/drush/drush.yml
Solution
I stumbled (and fell) upon the same issue today.
Following your work (missing composer.json at drupal's docroot), I was able to get over this problem, by making sure scaffolding was in place (inside drupal-project's composer.json). i.e.:
"post-install-cmd": [
"@drupal-scaffold",
"DrupalProject\\composer\\ScriptHandler::createRequiredFiles"
],
"post-update-cmd": [
"@drupal-scaffold",
"DrupalProject\\composer\\ScriptHandler::createRequiredFiles"
]
This may be quite obvious but got drush 9.2.1 working fine for me.
Good luck
OTHER TIPS
I has this issue and found this to work:
rm -Rf vendor/drush
composer install
Credit: https://github.com/drush-ops/drush/issues/2959#issuecomment-332054773
This deletes drush and uses the composer.lock file to re-instate drush from the version specified there.
Version of drush is 9.5.2 on my setup (after running above command at time of writing).
I had this issue when upgrading from drush 8 to drush 9.
Drush was failing to find the settings files on the server I deployed to.
When creating the artifact for deployment, I had previously stripped out unnecessary files, including __PROJECT_ROOT__/composer.json
.
It turns out, when I made sure __PROJECT_ROOT__/composer.json
was included on the server, drush 9 found the settings files, and the database connection.