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?

2 Answers 2

16

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.

5
  • 1
    Also note that alias discovery locations are more limited by default in 9. Nov 26, 2017 at 3:14
  • updated link, github.com/drush-ops/drush/blob/master/examples/…
    – troseman
    Dec 4, 2017 at 20:12
  • running this generated the yml files, but they are empty for some reason.
    – Ronnie
    Feb 27, 2018 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/… Mar 8, 2018 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, 2018 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.

1
  • 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, 2019 at 14:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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