How to fix drush issue "Could not bootstrap at phase 5"?

I installed drush via Composer. I am using drush 9.5.2 with Drupal 8.6.4.

I mention that everything is fine on local. However, in a docker instance in GitLab CI, when I execute vendor/bin/drush updatedb -y -vvv, I get:

 [preflight] Config paths: /builds/v2/my-project/vendor/drush/drush/drush.yml,/builds/v2/my-project/drush/drush.yml  [preflight] Alias paths: /builds/v2/my-project/web/drush/sites,/builds/v2/my-project/drush/sites  [preflight] Commandfile search paths: /builds/v2/my-project/vendor/drush/drush/src,/builds/v2/my-project/drush  [bootstrap] Starting bootstrap to full [0.09 sec, 8.27 MB]  [bootstrap] Drush bootstrap phase 5 [0.09 sec, 8.27 MB]  [bootstrap] Try to validate bootstrap phase 5 [0.09 sec, 8.27 MB]  [bootstrap] Try to validate bootstrap phase 5 [0.09 sec, 8.27 MB]  [bootstrap] Try to bootstrap at phase 5 [0.09 sec, 8.4 MB]  [bootstrap] Drush bootstrap phase: bootstrapDrupalRoot() [0.09 sec, 8.4 MB]  [bootstrap] Change working directory to /builds/v2/my-project/web [0.09 sec, 8.4 MB]  [bootstrap] Initialized Drupal 8.6.4 root directory at /builds/v2/my-project/web [0.1 sec, 8.4 MB]  [bootstrap] Try to validate bootstrap phase 5 [0.1 sec, 8.4 MB]  [bootstrap] Try to bootstrap at phase 5 [0.1 sec, 8.92 MB]  [bootstrap] Drush bootstrap phase: bootstrapDrupalSite() [0.1 sec, 8.92 MB]  [bootstrap] Initialized Drupal site default at sites/default [0.1 sec, 8.92 MB]  [bootstrap] Try to validate bootstrap phase 5 [0.1 sec, 8.92 MB]  [bootstrap] Try to bootstrap at phase 5 [0.1 sec, 8.92 MB]  [bootstrap] Drush bootstrap phase: bootstrapDrupalConfiguration() [0.1 sec, 8.92 MB]  [debug] Add service modifier [0.11 sec, 9.14 MB]  [bootstrap] Try to validate bootstrap phase 5 [0.11 sec, 9.14 MB]  [info] sql-query: SELECT 1; [0.11 sec, 9.28 MB]  [info] Executing: mysql --defaults-file=/tmp/drush_FfJCYU --database=my_project --host=xxx.rds.amazonaws.com --port=3306 --silent -A < /tmp/drush_BsP1AL > /dev/null [0.11 sec, 9.28 MB]  [info] sql-query: SELECT 1 FROM key_value LIMIT 1; [0.23 sec, 9.28 MB]  [info] Executing: mysql --defaults-file=/tmp/drush_TOHYme --database=my_project --host=xxx.rds.amazonaws.com --port=3306 --silent -A < /tmp/drush_4SNKF4 > /dev/null [0.23 sec, 9.28 MB]  [notice] Missing database table: key_value [0.35 sec, 9.28 MB]  [bootstrap] Could not bootstrap at phase 5 [0.35 sec, 9.28 MB]  In BootstrapHook.php line 32:    [Exception]                                                            Bootstrap failed. Run your command with -vvv for more information.     Exception trace:  () at /builds/v2/my-project/vendor/drush/drush/src/Boot/BootstrapHook.php:32  DrushBootBootstrapHook->initialize() at /builds/v2/my-project/vendor/consolidation/annotated-command/src/Hooks/Dispatchers/InitializeHookDispatcher.php:34  ConsolidationAnnotatedCommandHooksDispatchersInitializeHookDispatcher->callInitializeHook() at /builds/v2/my-project/vendor/consolidation/annotated-command/src/Hooks/Dispatchers/InitializeHookDispatcher.php:27  ConsolidationAnnotatedCommandHooksDispatchersInitializeHookDispatcher->initialize() at /builds/v2/my-project/vendor/consolidation/annotated-command/src/CommandProcessor.php:117  ConsolidationAnnotatedCommandCommandProcessor->initializeHook() at /builds/v2/my-project/vendor/consolidation/annotated-command/src/AnnotatedCommand.php:391  ConsolidationAnnotatedCommandAnnotatedCommand->initialize() at /builds/v2/my-project/vendor/symfony/console/Command/Command.php:221  SymfonyComponentConsoleCommandCommand->run() at /builds/v2/my-project/vendor/symfony/console/Application.php:971  SymfonyComponentConsoleApplication->doRunCommand() at /builds/v2/my-project/vendor/symfony/console/Application.php:248  SymfonyComponentConsoleApplication->doRun() at /builds/v2/my-project/vendor/symfony/console/Application.php:148  SymfonyComponentConsoleApplication->run() at /builds/v2/my-project/vendor/drush/drush/src/Runtime/Runtime.php:112  DrushRuntimeRuntime->doRun() at /builds/v2/my-project/vendor/drush/drush/src/Runtime/Runtime.php:41  DrushRuntimeRuntime->run() at /builds/v2/my-project/vendor/drush/drush/drush.php:66  require() at /builds/v2/my-project/vendor/drush/drush/drush:4  updatedb [--cache-clear [CACHE-CLEAR]] [--entity-updates] [--post-updates [POST-UPDATES]] [--no-cache-clear] [--no-post-updates] [-h|--help] [-q|--quiet] [-v|vv|vvv|--verbose] [-V|--version] [--ansi] [--no-ansi] [-n|--no-interaction] [-d|--debug] [-y|--yes] [--no] [--remote-host REMOTE-HOST] [--remote-user REMOTE-USER] [-r|--root ROOT] [-l|--uri URI] [--simulate] [--pipe] [-D|--define DEFINE] [--xh-link XH-LINK] [--notify [NOTIFY]] [--druplicon] [--] <command> 

I mention that the command mysql -V is working.

And when I execute vendor/bin/drush sql:connect -vvv, I get:

 [preflight] Config paths: /builds/v2/my-project/vendor/drush/drush/drush.yml,/builds/v2/my-project/drush/drush.yml  [preflight] Alias paths: /builds/v2/my-project/web/drush/sites,/builds/v2/my-project/drush/sites  [preflight] Commandfile search paths: /builds/v2/my-project/vendor/drush/drush/src,/builds/v2/my-project/drush  [bootstrap] Starting bootstrap to max [0.1 sec, 8.27 MB]  [bootstrap] Drush bootstrap phase: bootstrapDrupalRoot() [0.1 sec, 8.4 MB]  [bootstrap] Change working directory to /builds/v2/my-project/web [0.1 sec, 8.4 MB]  [bootstrap] Initialized Drupal 8.6.4 root directory at /builds/v2/my-project/web [0.1 sec, 8.4 MB]  [bootstrap] Drush bootstrap phase: bootstrapDrupalSite() [0.11 sec, 8.92 MB]  [bootstrap] Initialized Drupal site default at sites/default [0.11 sec, 8.92 MB]  [bootstrap] Drush bootstrap phase: bootstrapDrupalConfiguration() [0.11 sec, 8.92 MB]  [debug] Add service modifier [0.11 sec, 9.11 MB] mysql --user=my_project --password=xxx --database=my_project --host=xxx.rds.amazonaws.com --port=3306 -A 

So, no problem with drush sql:connect.

Does the notice “Missing database table: key_value” could cause the issue?
How could we troubleshoot the issue?

Just in case, here is the build part of my gitlab-ci.yml:

build:   stage: build    before_script:     - apt-get update      #install additional gd extension, that is required by Drupal     - apt-get install libpng-dev -y     - docker-php-ext-install gd      #install mysql-cli     - apt-get install -y mysql-client      #install composer     - apt-get install zip unzip     - php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"     - php composer-setup.php     - php -r "unlink('composer-setup.php');"      #install composer package to run parallel tasks     - composer -n global require -n "hirak/prestissimo"    script:     - mysql -V     - php composer.phar install     - vendor/bin/drush     - vendor/bin/drush sql:connect -vvv     - vendor/bin/drush updatedb -y -vvv     - vendor/bin/drush config-import -y     - vendor/bin/drush cache-rebuild -y 
This article was republished from its original source.
Call Us: 1(800)730-2416

Pixeldust is a 20-year-old web development agency specializing in Drupal and WordPress and working with clients all over the country. With our best in class capabilities, we work with small businesses and fortune 500 companies alike. Give us a call at 1(800)730-2416 and let’s talk about your project.

FREE Drupal SEO Audit

Test your site below to see which issues need to be fixed. We will fix them and optimize your Drupal site 100% for Google and Bing. (Allow 30-60 seconds to gather data.)

Powered by

How to fix drush issue "Could not bootstrap at phase 5"?

On-Site Drupal SEO Master Setup

We make sure your site is 100% optimized (and stays that way) for the best SEO results.

With Pixeldust On-site (or On-page) SEO we make changes to your site’s structure and performance to make it easier for search engines to see and understand your site’s content. Search engines use algorithms to rank sites by degrees of relevance. Our on-site optimization ensures your site is configured to provide information in a way that meets Google and Bing standards for optimal indexing.

This service includes:

  • Pathauto install and configuration for SEO-friendly URLs.
  • Meta Tags install and configuration with dynamic tokens for meta titles and descriptions for all content types.
  • Install and fix all issues on the SEO checklist module.
  • Install and configure XML sitemap module and submit sitemaps.
  • Install and configure Google Analytics Module.
  • Install and configure Yoast.
  • Install and configure the Advanced Aggregation module to improve performance by minifying and merging CSS and JS.
  • Install and configure Schema.org Metatag.
  • Configure robots.txt.
  • Google Search Console setup snd configuration.
  • Find & Fix H1 tags.
  • Find and fix duplicate/missing meta descriptions.
  • Find and fix duplicate title tags.
  • Improve title, meta tags, and site descriptions.
  • Optimize images for better search engine optimization. Automate where possible.
  • Find and fix the missing alt and title tag for all images. Automate where possible.
  • The project takes 1 week to complete.