Before recently settling into the path of using Vagrant + Ansible for site development (speaking of Ansible: I absolutely love it and need to blog about some of my fun with that), I had been using Acquia Dev Desktop. Even now, I'll use it from time to time since it is easy to work with.
However, I don't like using the version of drush it comes packaged with and prefer using my own version of drush via composer. I have a slew of reasons for this but ultimately, I am able to easily switch version of drush via composer so I can work with older sites vs. using drush HEAD so I can work on drush issues. In either case, trying to run your own version of drush with dev desktop (like running drush sql-sync) may lead to the following or similar errors:
Error: no database record could be found for target @self
And if you look inside the settings.php file, you will find something like the following:
// Please don't edit anything between <DDSETTINGS> tags.
// This section is autogenerated by Acquia Dev Desktop.
if (isset($_SERVER['DEVDESKTOP_DRUPAL_SETTINGS_DIR']) && file_exists($_SERVER['DEVDESKTOP_DRUPAL_SETTINGS_DIR'] . '/loc_MYSITE_dd.inc'))
require($_SERVER['DEVDESKTOP_DRUPAL_SETTINGS_DIR'] . '/loc_MYSITE_dd.inc');
Basically, Dev Desktop now moves database settings (plus anything else Acquia specific) to this include file and it gets included assuming the settings dir is in the server variable. From further investigation, I found that (atleast on OSX) the directory can be found at
$HOME/.acquia/DevDesktop/DrupalSettings. Dev Desktop Apache adds this setting as does Dev Desktop Drush, but your custom version of drush will not. To resolve the issue, we are defining
DEVDESKTOP_DRUPAL_SETTINGS_DIR as an environment variable. Drush will pick up environment variables and add them to $_SERVER for usage (which the settings.php file would, in this case). Add the following to your
~/.bash_profile file (or to any of the other files specified in this drush documentation):
And voila! Your favourite version of Drush will now work with Dev Desktop.