Drush doesn't work on my Mac

Drush doesn't work on my Mac

9 posts / 0 new
Last post
stephen@capellic.com's picture
stephen
Points: 0
Drush doesn't work on my Mac

I've used MAMP before on my machine along with Drush. But I've never been able to use Drush on the sites that I'm using within Dev Desktop 2. I get a boostrap error:

% drush en auto_nodetitle
Command pm-enable 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 'en auto_nodetitle' 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.

I heard that this might be due to Drush not using Dev Desktop's version of PHP (https://drupal.org/node/1465956). But any mention of Dev Desktop is referring to Dev Desktop 1. I am using 2.

This command gets me the status:

% /Applications/Acquia\ Dev\ Desktop/php5_3/bin/php /Applications/Acquia\ Dev\ Desktop/drush/drush.php status

But trying to enable the module gives me the bootstrap error again.

% /Applications/Acquia\ Dev\ Desktop/php5_3/bin/php /Applications/Acquia\ Dev\ Desktop/drush/drush.php en auto_nodetitle

Ideas?

Status: 
Unresolved
stephen@capellic.com's picture
stephen
Points: 0

I would hope that this post would get some sort of attention from Acquia-- does Acquia support monitor this forum?

jack@jackfoust.com's picture
jack
Points: 0

Ran into what I believe to be the same issue last night with Dev Desktop 2 beta on Windows. I was able to get Drush to finally use the "same PHP" that DD2 was using, however that did not resolve the issue. What I found later was that DD2 actually installs its own version of Drush which I was able to access through the DD2 control panel under More / Open Console. You may have this same option on your Mac.

stephen@capellic.com's picture
stephen
Points: 0

Thanks for the tip, but no luck here. Here's what I see in Terminal on the Mac after I click on that Open Console link and then try 'drush status' -- there must be something particularly odd about my computer.

/var/folders/wk/zd_vhxt88v5g3j006s6g2bn00000gn/T/DevDesktopConsole
[capellic:~] stephenm% /var/folders/wk/zd_vhxt88v5g3j006s6g2bn00000gn/T/DevDesktopConsole
bash-3.2$ drush status
bash: /Applications/Acquia Dev Desktop/drush/drush.php: No such file or directory
bash-3.2$

stephen@capellic.com's picture
stephen
Points: 0

Took a closer look and it appears my .bashrc file had some wrong paths it due to Acquia changing the app directory from "Acquia Dev Desktop" to "Dev Desktop" some versions back. So how here's what I've got in my .bashrc file:

alias drush='DRUSH_PHP=/Applications/Dev\ Desktop/php5_5/bin/php /Applications/Dev\ Desktop/drush/drush.php'
PATH=$PATH:/Applications/Dev\ Desktop/drush/drush.php

I'm still getting the bootstrap error above when executing "drush en devel" in the docroot of a site after launching terminal from Dev Desktop. Everything here looks good:

bash-3.2$ drush en devel
Command pm-enable needs a higher bootstrap level to run - you will need to invoke drush from a more functional Drupal environment to run this command. [error]
The drush command 'en devel' could not be executed. [error]
Drush was not able to start (bootstrap) the Drupal database. [error]
Hint: This may occur when Drush is trying to:
* bootstrap a site that has not been installed or does not have a configured database. In this case you can select another site with a working database setup by specifying the URI to use
with the --uri parameter on the command line. See `drush topic docs-aliases` for details.
* connect the database through a socket. The socket file may be wrong or the php-cli may have no access to it in a jailed shell. See http://drupal.org/node/1428638 for details.

Drush was attempting to connect to:
Drupal version : 7.26
Site URI : http://default
Database driver : mysql
Database username : root
Database name : challenge
Default theme : garland
Administration theme : garland
PHP configuration : "/Applications/Dev Desktop/php5_3/bin/php.ini"
PHP OS : Darwin
Drush version : 6.2.0
Drush configuration : "/Applications/Dev Desktop/drush/drushrc.php"
Drush alias files : /Users/stephenm/.acquia/DevDesktop/Drush/Aliases/capellic.aliases.drushrc.php /Users/stephenm/.acquia/DevDesktop/Drush/Aliases/capellicfree.aliases.drushrc.php
/Users/stephenm/.acquia/DevDesktop/Drush/Aliases/loc.aliases.drushrc.php /Users/stephenm/.acquia/DevDesktop/Drush/Aliases/sfa.aliases.drushrc.php
Drupal root : /Users/stephenm/Sites/devdesktop/susanfurukawaaspcaorg-dev/docroot
Site path : sites/default
File directory path : sites/default/files

jack@jackfoust.com's picture
jack
Points: 0

One of the articles I read when I was first struggling with this and had the bootstrap type issues was regarding PHP issues. I'm wondering if Drush using PHP 5.5, but your apache using PHP 5.3 is causing you issues. I believe you can override the PHP path in the drush config, I just don't remember which one off the top of my head. Dev Desktop 2 on Windows had an update over the last week, did the Mac one also? Wondering if any bugs were fixed.

jose.moreira's picture
Jose Mario Moreira de Oliveira
Points: 0

It worked for me on Mac Yosemite, thanks Jack!
I uninstalled Drush and used it from the DD2 console.

aron.beal.biz@gmail.com's picture
aron.beal.biz
Points: 0

An addendum to this thread - I was experiencing the "drush not able to bootstrap" issue here, same as others. In my case, however, the reason was entirely different - the install was using the correct php and mysql versions installed with dev desktop. Whenever I tried to do a non-trivial drush task like enabling a module, however, I got "Command pm-enable needs a higher bootstrap level to run - you will
need to invoke drush from a more functional Drupal environment to run this command."

When invoking mysql manually, the problem became apparent (this is on a Mac):

/Applications/DevDesktop/mysql/bin/mysql drupal_7_38
error: Found option without preceding group in config file: /Users/[my username]/.my.cnf at line: 1

My .my.cnf file was set up with a "password=mysupersecretpassword" line to allow easier authentication to mysql via the OSX Terminal. It was this line that was causing the connection failure - commenting it out allowed mysql to connect appropriately.

This may be an edge case, but it exhibited the same symptoms as the problem above, so I wanted to add it in case it helps someone else down the road.

dan@kor.com's picture
dan
Points: 0

Quick answer to some cases.
Try 'which drush'. If you have installed one at /usr/local/bin/drush it may not work with DevDesktop instance. Try running for example, /Applications/DevDesktop/drush/drush cr

This helped me with a failure, PDOException: SQLSTATE[HY000] [2002] Connection refused in docroot/core/lib/Drupal/Core/Database/Driver/mysql/Connection.php:142