Edit: the readme had what I needed to do to get it to work, but something about the wording made it hard to follow. So this is more about making it easier to do what needs to be done.

I suggest adding something to the readme to give a hint regarding the

Command pm-list needs a higher bootstrap level to run - you will need invoke drush from [error]
a more functional Drupal environment to run this command.
Command pm-list needs the following module installed/enabled to run: pm.                [error]
The drush command 'pm-list' could not be executed.                                      [error]
Drush was not able to start (bootstrap) the Drupal database.                            [error]
Hint: This error often occurs when Drush is trying to bootstrap a site that has not been
installed or does not have a configured database.

....

You can select another site with a working database setup by specifying the URI to use
with the --uri parameter on the command line or $options['uri'] in your drushrc.php
file.

This is related to issues like #437642: support for different MYSQL socket and #1011932: Support unix_socket in D7 $databases var in settings.php

patch coming.

Comments

yesct’s picture

StatusFileSize
new706 bytes

patch adds to the README

Users of the MAMP stack might want to change localhost to 127.0.0.1 in the
'$db_url' line in the settings.php file to workaround the 'needs a higher 
bootstrap level to run' error, or follow the MYSQL socket issue 
http://drupal.org/node/437642. 
yesct’s picture

StatusFileSize
new1.55 KB

this patch changes the command line hint to:

Command pm-list needs a higher bootstrap level to run - you will need invoke drush from [error]
a more functional Drupal environment to run this command.
The drush command 'pm-list' could not be executed.                                      [error]
Drush was not able to start (bootstrap) the Drupal database.                            [error]
Hint: This error often occurs when Drush is trying to bootstrap a site that has not been
installed or does not have a configured database. MAMP stack users whose database is
installed and configured might workaround this error by changing localhost to 127.0.0.1
in the settings.php file or follow the MYSQL socket issue http://drupal.org/node/437642.

...

You can select another site with a working database setup by specifying the URI to use
with the --uri parameter on the command line or $options['uri'] in your drushrc.php
file.
yesct’s picture

To clarify, the patch in comment 1 is just for the README file and the patch in comment 2 is just for the command line hint. So, either or both could be used.

yesct’s picture

ok. well that 127.0.0.1 only appears to work for D6... so. in the least, the hint I suggested adding should mention that.

yesct’s picture

#1016268-12: Command pm-enable needs a higher bootstrap level to run on MAMP says something I think is key: "#437642: support for different MYSQL socket added support for unix_socket, so if you have it setup correctly in your sites settings.php it should work properly.

The actual issue here is a misconfiguration in mysql and/or php, usually as a result of the website using one php config while php-cli uses another. If you modify settings.php and add a unix_socket to the database configuration you can force Drupal and Drush to use the same socket."

I'm just not quite sure what that translates directly into me needing to do.

in D7 in settings.php there are some lines like:

$databases = array (
  'default' =>
  array (
    'default' =>
    array (
      'database' => 'd7dm',
      'username' => 'root',
      'password' => 'root',
      'host' => 'localhost',
      'port' => '',
      'driver' => 'mysql',
      'prefix' => '',
    ),
  ),
);

I was reading around and found #561400: No way to specify MySQL socket with DBTNG and reading that patch, I'm thinking maybe what Kjartan is saying is that I need to:

$databases = array (
  'default' =>
  array (
    'default' =>
    array (
      'database' => 'd7dm',
      'username' => 'root',
      'password' => 'root',
      'host' => 'localhost',
      'port' => '',
      'unix_socket' => '',
      'driver' => 'mysql',
      'prefix' => '',
    ),
  ),
);

and actually set unix_socket to something.

yesct’s picture

I re-read very very carefully the README.txt (I know, that's what it means: read me.)

line 183:

If Drush is using the same php.ini file as the web server, you can create a
php.ini file exclusively for Drush by copying your web server's php.ini file to
the folder $HOME/.drush or the folder /etc/drush.  Then you may edit this file
and change the settings described above without affecting the php enviornment
of your web server.

So I checked one of my sites locally that had a info.php file in it.
looking at http://localhost/oneofmysiteslocally/info.php

Loaded Configuration File:
/Applications/MAMP/conf/php5/php.ini 

And I looked at the results of drush pm-list:

$ drush pm-list
Command pm-list needs a higher bootstrap level to run - you will need invoke drush from [error]
a more functional Drupal environment to run this command.
Command pm-list needs the following module installed/enabled to run: pm.                [error]
The drush command 'pm-list' could not be executed.                                      [error]
Drush was not able to start (bootstrap) the Drupal database.                            [error]
Hint: This error often occurs when Drush is trying to bootstrap a site that has not been
installed or does not have a configured database.

Drush was attempting to connect to : 
  Drupal version    : 7.13-dev
  Site URI          : http://***
  Database driver   : mysql
  Database hostname : localhost
  Database username : ***
  Database name     : ***
  Default theme     : garland
  Administration theme: garland
  PHP configuration : /private/etc/php.ini
  Drush version     : 5.0-dev
  Drush configuration: 
  Drupal root       : /Users/***/***/***
  Site path         : sites/default
  Modules path      : sites/all/modules
  Themes path       : sites/all/themes
  File directory path: sites/default/files
  %paths            : Array

You can select another site with a working database setup by specifying the URI to use
with the --uri parameter on the command line or $options['uri'] in your drushrc.php
file.

I checked the ini line:

  PHP configuration : /private/etc/php.ini

And concluded: "my drush is using a different php.ini file than the webserver."
So.. the readme paragraph that begins: If Drush is using the same php.ini file as the web server, made me think that I did NOT need to do what is if the then part of that paragraph. But since I've been working on this for a while I was willing to try it anyway and see if it helped.

So I copied the webserver php ini file to my ~/.drush:
cp /Applications/MAMP/conf/php5/php.ini ~/.drush/php.ini

I also checked for this caution in the readme:

Drush requires a fairly unrestricted php environment to run in.  In particular,
you should insure that safe_mode, open_basedir, disable_functions and
disable_classes are empty.

safe_mode was off and the rest empty. So I that is ok.

For D7, without changing localhost to 127.0.0.1, without changing ports, or making a unix_socket, and just copying the MAMP php.ini to ~/.drush, the bootstrap error goes away and I'm able to do several common drush commands. (there might be some special cases that that still need to make the unix_socket, but I dont know about that.)

Removing the php.ini from ~/.drush, breaks drush commands like drush pm-list and copying it back, makes it work.

I'd like to get some confirmation from someone that this solution works for others and is not specific for me, and I'd like make a new patch to improve the readme text.

yesct’s picture

I talked to Kjartan in the coder lounge and he said that really someone needs to file an issue with MAMP, that the MAMP people have to fix... uh something. And he helped clarify some things for me. I'll write a patch for the README.

greg.1.anderson’s picture

I don't have anything to say about MAMP, but your observations about php.ini in #6 are correct. Presumably, you could edit /private/etc/php.ini to match what you put in ~/.drush to the same effect, but if you want to insure that your php.ini changes are specific to Drush, then ~/.drush/php.ini is the way to go.

yesct’s picture

Mark helped me figure out what I really needed to do. And it's in a different part of the README. So I'll write up something to maybe make the README more clear about how to get the right php in the path (how to find out which php version MAMP is running, and how to find out the path for php).

yesct’s picture

StatusFileSize
new3.25 KB

Here is something Martin and Erik and I and some other people worked on.

It splits out some of the nitty gritty into a trouble shooting part. And tries to describe in general the steps in case the given exact lines to cut and paste don't work.

yesct’s picture

StatusFileSize
new1.27 KB

this is a patch for the command line hint for bootstrap error.

adds "This error might also occur when the php the command line drush command is using is not the same php that the webserver is using. See the README.txt file." to the hint. changing the hint from:

$ drush pm-list
Command pm-list needs a higher bootstrap level to run - you will need      [error]
invoke drush from a more functional Drupal environment to run this command.
The drush command 'pm-list' could not be executed.                         [error]
Drush was not able to start (bootstrap) the Drupal database.               [error]
Hint: This error often occurs when Drush is trying to bootstrap a site that
has not been installed or does not have a configured database. This error
might also occur when the php the commandline drush command is using is not
the same php that the webserver is using. See the README.txt file.

Drush was attempting to connect to : 
...

You can select another site with a working database setup by specifying the
URI to use with the --uri parameter on the command line or $options['uri']
in your drushrc.php file.

to

$ drush pm-list
Command pm-list needs a higher bootstrap level to run - you will need      [error]
invoke drush from a more functional Drupal environment to run this command.
The drush command 'pm-list' could not be executed.                         [error]
Drush was not able to start (bootstrap) the Drupal database.               [error]
Hint: This error often occurs when Drush is trying to bootstrap a site that
has not been installed or does not have a configured database. This error
might also occur when the php the command line drush command is using is
not the same php that the webserver is using. See the README.txt file.

Drush was attempting to connect to : 
...

You can select another site with a working database setup by specifying the
URI to use with the --uri parameter on the command line or $options['uri']
in your drushrc.php file.

This patch is instead of the patch in comment #2 (drush-commandlinehint127-1493022-2.patch). This patch (drush-commandlinehint-1493022-11.patch) is better because it's more technically accurate and general
and refers to the README.txt file so people will know to look there for how to fix the problem.

yesct’s picture

Title: Add suggestion to change localhost to 127.0.0.1 when "needs a higher bootstrap level to run" (relates to mac MYSQL socket) » improve readme and add "have command line use same php as webserver" for hint for "needs a higher bootstrap level to run" error

changing title.

greg.1.anderson’s picture

Version: » 8.x-6.x-dev
Status: Active » Closed (won't fix)
Issue tags: +Needs migration

This issue was marked closed (won't fix) because Drush has moved to Github.

If this feature is still desired, you may copy it to our Github project. For best results, create a Pull Request that has been updated for the master branch. Post a link here to the PR, and please also change the status of this issue to closed (duplicate).

Please ask support questions on Drupal Answers.

greg.1.anderson’s picture

Issue summary: View changes

adding comment about how readme is correct, but hard to follow