Blob of contradictions

Using Dev Desktop with Composer Drush


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:

  1. 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:

  2. // Please don't edit anything between <DDSETTINGS> tags.
  3. // This section is autogenerated by Acquia Dev Desktop.
  6. //</DDSETTINGS>

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):

  1. export DEVDESKTOP_DRUPAL_SETTINGS_DIR="$HOME/.acquia/DevDesktop/DrupalSettings"

And voila! Your favourite version of Drush will now work with Dev Desktop.