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

Remove shell alias replacements #1369

Closed
ann--b opened this issue May 8, 2015 · 11 comments
Closed

Remove shell alias replacements #1369

ann--b opened this issue May 8, 2015 · 11 comments

Comments

@ann--b
Copy link

ann--b commented May 8, 2015

$drush --version ---> 7.0-dev


The following command works:

$ drush sql-sync @stg @dev --create-db --sanitize


The following command, using shell alias replacements, does not work:

$drush @dev pull-db -v


drushrc.php

$options['shell-aliases']['pull-db'] = 'sql-sync {{#stg}} {{@target}} --create-db --sanitize';


aliases.drushrc.php:

$aliases['dev'] = array(
'uri' = 'local_uri',
'root' = 'local_drupal_root',
'variables' = array('mail_system' = array('default-system' = 'DevelMailLog')),
'path-aliases' = array(
'%dump' = '/home/local_user/drush-dump/dev-foo-' . date('Ymdhis') . '.sql',
),
'#stg' = '@stg',
'#drupal-root' = 'local_drupal_root',
);
$aliases['stg'] = array(
'uri' = 'remote_ip',
'root' = 'remote_drupal_root',
'remote-host' = 'remote_ip',
'remote-user' = 'remote_user',
'path-aliases' = array(
'%dump' = '/home/remote_user/drush-dump/stg-foo-' . date('Ymdhis') . '.sql',
)
);


Output from $drush @dev pull-db -v:

Loaded alias @dev from file /home/local_user/.drush/aliases.drushrc.php [notice]
Initialized Drupal 7.33 root directory at local_drupal_root [notice]
Initialized Drupal site local_uri at sites/default [notice]
Loaded alias @stg from file /home/local_user/.drush/aliases.drushrc.php [notice]
ssh -o PasswordAuthentication=no remote_user@remote_ip 'COLUMNS=120 drush --backend=2 --verbose --uri=remote_ip [notice]
--root=remote_drupal_root sql-conf --all 2&1' 2&1
/usr/bin/php /usr/local/lib/drush/drush.php --php=/usr/bin/php --backend=2 --verbose [notice]
--uri=local_uri --root=local_drupal_root sql-conf --all 2&1
You will destroy data in db_name and replace with data from remote_ip/db_name.
Do you really want to continue? (y/n): y
Starting to create database on Destination. [ok]
/usr/bin/php /usr/local/lib/drush/drush.php --php=/usr/bin/php --backend=2 --verbose [notice]
--uri=local_uri --root=local_drupal_root --strict=0 sql-create --create-db --sanitize 2&1
Initialized Drupal 7.33 root directory at local_drupal_root [notice]
Initialized Drupal site local_uri at sites/default [notice]
Creating database db_name. Any possible existing database will be dropped!
Do you really want to continue? (y/n): y
Executing: mysql --defaults-extra-file=/tmp/drush_uKQ4PV --database=information_schema --host=localhost --silent /tmp/drush_2dnfDM
Command dispatch complete [notice]
Starting to dump database on Source. [ok]
ssh -o PasswordAuthentication=no remote_user@remote_ip 'COLUMNS=120 drush --backend=2 --verbose [notice]
--uri=local_uri --root=local_drupal_root --strict=0 sql-dump --create-db --sanitize --gzip
--result-file 2&1' 2&1
Unable to load class Drush\Sql\Sql [error]
exception 'Drush\Sql\SqlException' with message 'Unable to find a matching SQL Class. Drush cannot find your [error]
database connection details.' in /usr/local/lib/drush/commands/sql/sql.drush.inc:669
Stack trace:
#0 /usr/local/lib/drush/commands/sql/sql.drush.inc(348): drush_sql_get_class()
#1 [internal function]: drush_sql_dump()
#2 /usr/local/lib/drush/includes/command.inc(359): call_user_func_array('drush_sql_dump', Array)
#3 /usr/local/lib/drush/includes/command.inc(210): _drush_invoke_hooks(Array, Array)
#4 [internal function]: drush_command()
#5 /usr/local/lib/drush/includes/command.inc(178): call_user_func_array('drush_command', Array)
#6 /usr/local/lib/drush/lib/Drush/Boot/DrupalBoot.php(46): drush_dispatch(Array)
#7 /usr/local/lib/drush/drush.php(76): Drush\Boot\DrupalBoot-bootstrap_and_dispatch()
#8 /usr/local/lib/drush/drush.php(16): drush_main()
#9 {main}

Command dispatch complete [notice]
sql-dump failed. [error]
Command dispatch complete


It appears the local uri and local drupal root were sent to the remote server.

ssh -o PasswordAuthentication=no remote_user@remote_ip 'COLUMNS=120 drush --backend=2 --verbose [notice]
--uri=local_uri --root=local_drupal_root --strict=0 sql-dump --create-db --sanitize --gzip
--result-file 2&1' 2&1

Thank you.

@greg-1-anderson
Copy link
Member

sql-sync was simplified and streamlined in Drush 7.

@weitzman - did you deliberately remove this feature, or is it in theory still supported?

@weitzman
Copy link
Member

weitzman commented May 9, 2015

I dont understand the problem yet, despite rereading this a couple times. But regardless, site aliases can carry shell aliases and thus you could define pull-db completely inside of @dev and thus avoid shell alias replacements entirely. See https://github.com/drush-ops/drush/blob/6.x/examples/example.aliases.drushrc.php#L327

@ann--b
Copy link
Author

ann--b commented May 11, 2015

This has to be run as a bash command and not a drush command. The following change in drushrc.php fixed the problem.:

$options['shell-aliases']['pull-db'] = '!drush sql-sync {{#stg}} {{@target}} --create-db --sanitize';

Thank you.

@ann--b ann--b closed this as completed May 11, 2015
@greg-1-anderson
Copy link
Member

I think we need to consider whether the feature described by ann--b can be made consistent, or whether we should remove it.

@weitzman weitzman changed the title sql-sync combined with replacements not working Remove shell alias replacements May 15, 2015
@weitzman
Copy link
Member

We have decided to remove shell alias replacements feature due to low usage. See my earlier suggestion to put shell alias definition in the site alias.

@frederickjh
Copy link
Contributor

@weitzman With Drush aliases moving to yaml files will it still be possible to include Drush shell aliases inside a Drush site alias?
See https://github.com/drush-ops/drush/blob/6.x/examples/example.aliases.drushrc.php#L327

@frederickjh
Copy link
Contributor

The documentation on Drush shell aliases needs to be updated to reflect this change to remove shell alias replacements other than the special {{@target}}.
https://github.com/drush-ops/drush/blob/master/docs/shellaliases.md
http://www.drush.org/en/master/shellaliases/

@weitzman
Copy link
Member

I dont think anyone has gotten around to simplifying shell aliases. Thanks for the reminder to adjust docs when that does happen.

@frederickjh
Copy link
Contributor

One other thing I just noticed (Drush Version : 8.1.8). When Drush shell aliases are place in a Drush site alias file doing:
drush sha or drush @sitealias sha does not list them.

Drush help says:

shell-alias (sha) Print all known shell alias records.

So, either the help needs changed or code needs added that finds Drush shell aliases inside Drush site alias files.

@weitzman
Copy link
Member

@frederickjh - that looks like a bug report independant of replacements. Please create a new issue. Thanks for the report.

Regarding your earlier question, there is no current plan to remove the ability for site aliases to specify shell aliases.

@greg-1-anderson
Copy link
Member

Drush 8 is maintenance only, and Drush 9 does not have shell aliases. Closing.

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