OK - I finally got to the bottom of this and it is working.
In order to get this to work all I needed to do was add the path of ANY alias file or files to each project's Drush config file i.e. drush.yml
as well as my own local one.
You can name it whatever you like, self.site.yml
or foo.site.yml
if you wish, there is no need for a special first name, all you need is myname.site.yml
. I have tested this and created two identical alias files with different names:
self.site.yml
foo.site.yml
Both or these files reside in my ~/.drush directory
but that is also not important as long as the path is defined in drush.yml in both your local drush installation AND in each project. Remember, you may have different versions of Drush per project.
When I do drush sa
:
'@foo.foo':
root: /var/www/my_site/web
uri: 'https://mysite.mydomain.com
'@self.uat':
root: /var/www/my_site/web
uri: 'https://my_site'
Both drush @uat status
and drush @foo status
work equally well as they point to the same Drupal root.
The location of the sites aliases file also makes no difference. Changing the location of my sites alias path to 'bar' instead of drush or .drush is fine as long as the local and project drush.yml are aligned. This is how it looks in all my drush.yml
files now:
paths:
alias-path:
- '${env.HOME}/.drush/sites'
I could equally have used ${env.HOME}/.drush/sites
, ${env.HOME}/drush/sites
or ${env.HOME}/bar/sites
I hope this helps others!