11

In Drush 8, my site aliases are loaded correctly from ~/.drush/mysite.aliases.drushrc.php.

E.g.

$aliases['dev'] = array(
  'root' => '/var/www/html/mysite.dev/docroot',
  'uri' => 'mysite.prod.acquia-sites.com',
  'remote-host' => 'mysite.ssh.acquia-sites.com',
  'remote-user' => 'mysite.dev',
  'path-aliases' => array(
    '%drush-script' => 'drush' . $drush_major_version,
  ),
);

However these aliases aren't loaded in Drush 9.

$ drush site-alias
{  }

How I should define site aliases in Drush 9? Is there any migration process?

14

Aliases are now provided in YAML files. According to the example aliases file for Drush 9:

To convert legacy alias (*.aliases.drushrc.php) to yml, run the site:alias-convert command.

So running the command:

drush site:alias-convert

should do the trick.

  • 1
    Also note that alias discovery locations are more limited by default in 9. – moshe weitzman Nov 26 '17 at 3:14
  • updated link, github.com/drush-ops/drush/blob/master/examples/… – troseman Dec 4 '17 at 20:12
  • running this generated the yml files, but they are empty for some reason. – Ronnie Feb 27 '18 at 19:03
  • 1
    Here is a bit more detailed breakdown of the steps needed to get drush 9 aliases working. drupal.stackexchange.com/questions/252751/… – TheRealWebGuy Mar 8 '18 at 20:01
  • 1
    Not sure how much the original aliases.drushrc.php influences this. Mine had three aliases in it (dev, staging, production), which generated three files, which only pertained to the local, but one had all three. I split these then according to my three builds, and deleted the rest, which is now working fine. – karolus Mar 27 '18 at 0:55
2

Clive's answer is a start, but as TheRealWebGuy notes, there is another step you must take.

I was upgrading from drush 8 to drush 9, and my aliases still did not work after running drush site:alias-convert. An additional step that I needed to take for my new alias files to work was to run drush init. I ran it in my user home directory; I don't know if that matters.

Hopefully this saves future users some additional clicking and searching.

  • drush init copies the local (project) configurations to your global (machine) drush configurations at ~/.drush. Do this if you want global aliases. – wranvaud Dec 4 at 14:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.