Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

drush rsync generates fatal error when using wildcard. #929

Open
kenorb opened this issue Oct 25, 2014 · 13 comments
Open

drush rsync generates fatal error when using wildcard. #929

kenorb opened this issue Oct 25, 2014 · 13 comments

Comments

@kenorb
Copy link
Contributor

kenorb commented Oct 25, 2014

I've the following sample drush alias files:

$ cat test1.aliases.drushrc.php 
<?php
$aliases['dev'] = array(
  'remote-host' => 'example.com',
);
$ cat test2.aliases.drushrc.php 
<?php
$aliases['dev'] = array(
  'remote-host' => 'example.com',
);

When I'm trying to rsync multiple files, but I've got the following error:

$  drush -vy --alias-path=. rsync test* @test1.dev
Fatal error: Cannot unset string offsets in ~/.composer/vendor/drush/drush/includes/sitealias.inc on line 1913
...
6. drush_command('test1.aliases.drushrc.php', 'test2.aliases.drushrc.php', '@test1.dev')
...
9. drush_core_rsync($source = 'test1.aliases.drushrc.php', $destination = 'test2.aliases.drushrc.php', $additional_options = '@test1.dev')
10. drush_sitealias_evaluate_path($path = 'test2.aliases.drushrc.php', $additional_options = '@test1.dev', $local_only = FALSE, $os = 'rsync', $command_specific_prefix = 'target-')

Variables in local scope (#10):
  $additional_options = '@test1.dev'
  $alias = NULL
  $command_specific_prefix = 'target-'
  $local_only = FALSE
  $machine = ''
  $os = 'rsync'
  $path = 'test2.aliases.drushrc.php'
  $path_aliases = array ()
  $preflight = array ('alias' => NULL, 'path' => 'test2.aliases.drushrc.php', 'machine' => '')
  $remote_user = ''
  $site_alias_settings = array ()

It is a bug, or you're just not allowed to do that?


Drush Version : 7.0-dev

@weitzman
Copy link
Member

I'm not clear what your source and path are, and what your dest and path are. Your desired outcome is unclear.

@kenorb
Copy link
Contributor Author

kenorb commented Oct 28, 2014

I'm trying to use rsync to transfer multiple files by using wildcard, e.g.

drush rsync settings* @remote

So I'm expecting two files to be transfered, settings.php and e.g. settings.local.php.

@weitzman
Copy link
Member

Please see the help for this command. You specify a path to the dir you
want to transfer, just like rsync. So drush rsync @self:/sites/default/ @remote. See the rsync docs for more info about wildcards. Or perhaps see
http://unix.stackexchange.com/questions/63406/rsync-all-directories-that-start-with-a-specific-digit

@kenorb
Copy link
Contributor Author

kenorb commented Oct 28, 2014

So it needs to be either single file or path, because drush doesn't support wildcards? rsync command normally accepts wildcard.

E.g.

$ mkdir 1 2
$ touch 1/test-1 1/test-2
$ rsync 1/test* 2/
$ ls 2/
test-1  test-2

The same test with drush:

$ mkdir 1 2
$ touch 1/test-1 1/test-2
$ drush rsync 1/test* 2/
Fatal error: Cannot unset string offsets

@kenorb kenorb changed the title Can't rsync multiple files because of fatal error. drush rsync generates fatal error when using wildcard. Oct 28, 2014
@weitzman
Copy link
Member

Please use site aliases in the arguments to drush rsync. In your example, You might as well use rsync as there is nothing Drupalish about it. There might still be a bug, but your example doesn't quite illustrate it. Thanks for sticking with this.

@kenorb
Copy link
Contributor Author

kenorb commented Oct 28, 2014

Drupalish sample use case:

  1. I've bunch of modules to rsync to remote, e.g. search_api, search_api_autocomplete, search_api_db, search_api_ranges, search_api_saved_searches, search_api_solr, but I don't want to rsync hundred of other modules in the same folder. So to avoid executing 5-10x drush, I'm trying to use wildcard (as normally I would use when using rsync).

  2. My 1st try (I can't use @self, as local instance in current dir is not installed):

    $ drush rsync dist/src/sites/all/modules/contrib/search_api* @remote.dev:sites/all/modules/contrib/
    Fatal error: Cannot unset string offsets in sitealias.inc on line 1913
    # Doesn't even trying to connect to the remote.
    
  3. My 2nd try:

    $ drush rsync dist/src/sites/all/modules/contrib/search_api\* @remote.dev:sites/all/modules/contrib/
    rsync: link_stat "src/sites/all/modules/contrib/search_api*" failed: No such file or directory (2)
    0 files to consider
    
  4. My 3rd try is to use -r to specify Drupal root for bootstraping, so I can use @self:

    $ drush -r dist/src rsync @self:dist/src/sites/all/modules/contrib/search_api* @remote.dev:sites/all/modules/contrib/
    Fatal error: Call to undefined function conf_path() in ~/.composer/vendor/drush/drush/lib/Drush/Boot/bootstrap.inc on line 570
    11. drush_bootstrap_validate($phase = 2) ~/.composer/vendor/drush/drush/lib/Drush/Boot/bootstrap.inc:340
    12. _drush_bootstrap_drupal_site_validate() ~/.composer/vendor/drush/drush/lib/Drush/Boot/bootstrap.inc:264
    
  5. Another try with @self within Drupal root, but using external drush alias files for remotes:

    $ drush --alias-path=../../drush rsync -r @self:sites/all/modules/contrib/search_api* @remote.dev:sites/all/modules/contrib/
    Undefined variable: destination rsync.core.inc:67
    Calling system(rsync -e 'ssh -o PasswordAuthentication=no' -rlptzOv --exclude=".git" --exclude=".gitignore" --exclude=".hg" --exclude=".hgignore" --exclude=".hgrags" --exclude=".bzr" --exclude=".bzrignore" --exclude=".bzrtags" --exclude=".svn" --stats --progress -r --no-perms --filter='exclude *.sql' drush@remote:/var/www/sites/all/modules/contrib/ );
    1 file to consider
    drwxr-xr-x        4096 2014/10/28 15:13:30 .
    

None of above drush rsync did work to transfer multiple dirs when using wildcard.

@weitzman
Copy link
Member

I just enhanced Drush to that the value of -r can be a relative path, as you do in #4.

I think you wanted to omit -r in #5. Otherwise that should have worked.

@weitzman
Copy link
Member

I should clarify that the --root issue looks fixed. There may be an incompatibility with Drush and wildcards. Feel free to submit a patch.

@kenorb
Copy link
Contributor Author

kenorb commented Oct 28, 2014

5th example was ran within Drupal root, so -r was not necessary. Second -r was used for rsync (recursive). Currently I can't test the fix, as I'm blocked by #938.

@weitzman
Copy link
Member

#938 is closed.

@kenorb
Copy link
Contributor Author

kenorb commented Nov 12, 2014

Testing on the latest drush.

Without @self:

$ drush -y rsync -ruv src/sites/all/modules/contrib/search_api* @remote:sites/all/modules/contrib/
Fatal error: Cannot unset string offsets in drush/includes/sitealias.inc on line 1841

With @self (without -r for root, but the same happens with -r):

$ drush -y rsync -ruv @self:src/sites/all/modules/contrib/search_api* @remote:sites/all/modules/contrib/
The source and destination cannot both be remote.
rsync error: syntax or usage error (code 1) at /SourceCache/rsync/rsync-42/rsync/main.c(1083) [receiver=2.6.9]

@cferthorney
Copy link

This appears to still be an issue with db55a72 (Latest as of 27 Feb 2015 according to compser global update)

drush rsync /Users/David/Development/main-client/code/sites/en/themes/uk/* @client-en.dev:%themes/uk
PHP Fatal error:  Cannot unset string offsets in Users/David/.composer/vendor/drush/drush/includes/sitealias.inc on line 1881

If anyone has any ideas I'd appreciate them. Happy to provide further debugging information if needed

@greg-1-anderson
Copy link
Member

Folks, drush rsync supports TWO parameters, no more, no less.

When you use wildcards, like test*, then the shell is going to expand the wildcards before passing them to Drush, so you will get more than two parameters.

$ drush -s rsync a b
Calling system(rsync -e 'ssh ' -rlptz --exclude=".git" --exclude=".gitignore" --exclude=".hg" --exclude=".hgignore" --exclude=".hgrags" --exclude=".bzr" --exclude=".bzrignore" --exclude=".bzrtags" --exclude=".svn" --exclude="settings.php" a b);
$ drush -s rsync a b c
Fatal error: Cannot unset string offsets in includes/sitealias.inc on line 1881

Now, the rsync command itself does support things like rsync a b c, which copies a and b to the destinatin, c. If it was really important to support this in Drush, we could consider enhancing rsync to do this as well. The initial usecase was to do things like drush rsync @live:%files @stage:%files. If there were multiple source files, do we allow an @alias on any of the source files? This is the complication. Perhaps > 2 parameters means that aliases are only supported on the target.

I somehow don't think that it is super pressing to support this, but I imagine a PR would be welcome.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants