NOTE: Client names are redacted, so some of the alias names or directory names may seem odd.
The command I'm attempting to run is
drush @example.prod rsync @self:%files/ @example.dev:%files
The short error message I receive is
rsync: --site=example: unknown option
rsync error: syntax or usage error (code 1) at main.c(1422) [client=3.0.6]
Could not rsync from [error]
/var/www/html/drupal/current/docroot/sites/default/files/ to
client@example.com:/var/www/html/dev/docroot/sites/default/files
Full debug output is attached.
Comments
Comment #1
erikwebb commentedMaybe this is a similar solution to - #1596916: include-vcs option gets passed directly to rsync
Comment #2
erikwebb commentedOnce we resolve this, --env is being passed in to rsync also and will likely cause another issue.
Comment #3
erikwebb commentedThis is only caused when additional options are set in the Drush alias -
It seems there must be a better solution that removing these just from the rsync commands, so unfortunately I'm going to have to leave this one up to someone more familiar with Drush's internals and internal workflow.
Comment #4
moshe weitzman commented@greg - is there a way to distinguish in an alias which options should go before the command versus after? Thats needed for strict commands like rsync.
Comment #5
greg.1.anderson commentedIn the example above, 'site' and 'env' are not options; they are metadata in the site alias. Drush passes all options from a site alias through to remote commands, except those that begin with a '#'; if the metadata items in the above site alias were renamed, then this wouldn't be a problem. For example:
If you did this, though, these options would not be passed through, which would be a problem if you wanted them available, e.g. to reference in an init hook or something like that.
For options defined in a site alias that are not named via this convention, then strict option commands such as rsync will not be able to tell if the option was intended to be passed to rsync, or if it is some other option that should be passed to Drush (and potentially just ignored). Maybe what we should do is, for strict option commands, assume that any options defined in a command-specific structure (e.g. for rsync) that is not recognized by name should be passed along as an rsync option (e.g. after the 'rsync' command), whereas options at the root level (e.g. 'prod' and 'env' in the examples above) will be presumed to not be rsync options, and will be passed along after the rsync command.
This change might break some people, but better to make a few people move a couple options into a command specific option, then to leave people who need global generic options without recourse.
Comment #6
erikwebb commentedFYI - the extra 'site' and 'env' keys are standard for Drush aliases provided by Acquia, so it's likely there are other people experiencing this problem without reporting.
Comment #7
moshe weitzman commentedI have filed a bug with Acquia about this.
Let's leave this open for a feature request to distinguish what extra data goes before and after the command. Not urgent, IMO
Comment #8
greg.1.anderson commentedWhat do you think about the idea that top-level options in the site alias are ignored, but command-specific options are included in drush strict option commands? I haven't looked into what it would take to implement, but I presume it wouldn't be too difficult. Could try it, if it seemed the desired behavior seems right. It doesn't seem like there is ever a time when a top-level option should be included in the strict options, so perhaps this is only an improvement. I think I should try to roll a patch.
Comment #9
moshe weitzman commentedThat sounds like an improvement, yes. I also had the idea to introduce a special '#strict' key and you'd nest your rsync options under that. No idea of thats better or easier to implement.
Comment #10
greg.1.anderson commentedStrict has to be command specific; if there are two strict commands, then it wouldn't do to mix the options for both of them together. I'll try my hand at a patch as soon as I have time. The key is to make sure that global options like 'site' and 'env' still get applied to the appropriate alias context, in case they are accessed in an init hook, etc., but to keep them out of the list of options built when getting all of the options to pass through to the strict options command.
Comment #11
greg.1.anderson commentedIt turns out that 'drush rsync @a @b' already did the right thing vis-a-vis strict option commands; it was only 'drush @a rsync ...' that was lacking. Command-specific was similarly unsupported when redispatching in this way. This patch fixes both problems.
Comment #12
moshe weitzman commentedNice. Do we need any new test coverage,? Maybe just a --simulate style assertion. Feel free to commit this when you are ready. Your call about backport as well.
Comment #13
greg.1.anderson commentedCommitted #11 + a test as ccd0cd9.
I am uncertain about the backport. It should be okay, but there are minor changes in behavior. For example, previously
drush @remote statuswould rundrush statuson the remote machine, but now the command alias is mapped to the full command name, sodrush core-statusis executed instead. Other changes of option order should all be considered bug fixes -- I expect, anyway. The differences are very unlikely to affect anyone, but if they did, it would be pretty mysterious. I guess this is eligible, but I haven't firmly decided to do it, is what it comes down to.Comment #15
moshe weitzman commentedI think we should backport this. The eligible commit is ccd0cd9. Can we cherry pick that diff or are further changes needed? The diff does apply cleanly.
Also, in your example from #13, I assume that `drush status` would get still run on the remote side if the status command did not exist on the local side. I'd rather not lose that feature.
Comment #16
greg.1.anderson commentedI'll have to test #15, but I believe it still works that way. Once I confirm, I will backport.
Comment #17
greg.1.anderson commentedDrush 6 no longer propagates generic site alias options to backend calls at all; only command-specific options are included on the command line.
Should we change the behavior of Drush 5 to match? This would involve cherry-picking ccd0cd9 and making minor modifications to it.
Comment #18
moshe weitzman commentedI think that would be too big a change. In fact, I'm not 100% sure that skipping generic site alias options is a good idea. I'm mulling that over. For drush5, backporting #13 makes sense.
Comment #19
greg.1.anderson commentedI cherry-picked ccd0cd9, and am running the test suite on it now. The command name is passed through as-is to the remote system if it does not exist locally.
Comment #20
greg.1.anderson commentedTest suite passed; committed to 7.x-5.x.