Acquia Dev Desktop – use Drush 7 for Drupal 7 sites

Issues

Using a local Drush (preferably composer installed Drush 7), instead of the Drush Acquia Dev Desktop (ADD) is shipping, doesn’t get the actual DB details of the website. The following error message will show up when you run:

vendor/drush/drush/drush.php --verbose --debug info

.
.
.
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.69
.
.
.

Solution

The reason for this is because the database details are not available to the Drush software.

To start, click the console icon on Acquia Dev Desktop:

A console with the localized Acquia variables should popup:

echo $DEVDESKTOP_DRUPAL_SETTINGS_DIR
// returns empty string
//
  
export DEVDESKTOP_DRUPAL_SETTINGS_DIR=$HOME/.acquia/DevDesktop/DrupalSettings
echo $DEVDESKTOP_DRUPAL_SETTINGS_DIR
// returns:
//  ~/.acquia/DevDesktop/DrupalSettings
  
vendor/drush/drush/drush --verbose --debug info
// returns
// Drush bootstrap phase : bootstrap_drupal_database() [0.27 sec, 5.39 MB]                                                                                                [bootstrap]
// Successfully connected to the Drupal database. [0.29 sec, 5.75 MB]                                                                                                     [bootstrap]