Skip to main content

Drush needs a higher bootstrap level to run (How to Fix)

Drush needs a higher bootstrap level to run

Problem: With a PHP update, all drush commands stopped working

1. The obvious debugging is running the pm-update or any drush command inside a Drupal folder. If it still throws a "needs a higher bootstrap level to run," go to step 2.

2. Check all your path files

vi ~/.bashrc
vi ~/.bash_profile

bashrc is run in Linux outside shell access for all apps under your username

bash_profile is run only when you use a shell through the terminal

Regardless, see if the right php version is running

3. Setting the right PHP Path

echo $PATH

To set a PATH, you can add the path after the colon (:) symbols like below using vim/vi or Nano or any editor of your choice. Do this for ~/.bashrc and ~/.bash_profile

PATH=$PATH:$HOME/bin

Or you can use the export command like below (only an example where composer's bin is added to the path. You can do the same for php)

export PATH=$HOME/.composer/vendor/bin:$PATH

4. How to see which PHP is running

php -v

You will see the version used for the terminal.

5. To see all the ini files - all PHP versions in the box, run (as root)

php --ini

6. To find which PHP drush is using, run

drush status --full

PHP configuration      :  /<path_to_php>/etc/php.ini
Drush version          :  8.4.12
Drush script           :  /<full_path_to_drush>

7. You can test if PHP is the issue by using the full PHP path like

/<path_to_php>/usr/bin/php /<full_path_to_drush> status

8. If 7 resolves the issue, it is about adding the <path_to_php> to the ~/.bashrc and ~/.bash_profile file

Make sure that you run the following commands after adding the PHP path.

source  ~/.bashrc
source  ~/.bash_profile

9. If 7 doesn't resolve the problem, find the default mysql socket (unix) by running the following command

php -i | grep ^pdo_mysql.default_socket
pdo_mysql.default_socket => /var/lib/mysql/mysql.sock => /var/lib/mysql/mysql.sock

10. If the default mysql.sock is present, then look for .my.cnf file in your home directory. A conflict with the .cnf file could throw this error as well

11. Rename .my.cnf 
mv .my.cnf .my.cnf_bak_now

12. run drush

13. If it throws any error related to "Memory Exhausted," etc., you are a step away

cd /<path_to_php>/etc

vi php.ini

14. Increase memory limit

memory_limit = 128M

15. Run drush inside a Drupal installation. The error should disappear

So to summarize, 4 causes that will throw the Drush "needs a higher bootstrap level" to run error.

1. You are not in a Drupal folder
2. The PHP path is wrong (your default php changed)
3. Your MySQL default socket is not set or got altered (Unix socket)
4. .my.cnf file in your home directory is conflicting with Drush's call to the database

 

Drupal