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

@validate-file-exists doesn't seem to take --root into account #3131

Closed
gaelg opened this issue Nov 2, 2017 · 7 comments
Closed

@validate-file-exists doesn't seem to take --root into account #3131

gaelg opened this issue Nov 2, 2017 · 7 comments
Assignees

Comments

@gaelg
Copy link
Contributor

gaelg commented Nov 2, 2017

I tried drush @docker sql-query --file=../private/$DUMP and got [error] File(s) not found: ../private/2017-11-02_17:12.sql
The same command work if I execute it directly inside the container, without any alias.
After some search, I found out that if I remove "@validate-file-exists file" from SQLCommands.php function query(), it works. I tried a getcwd() in validateFileExists(), before the call to file_exists() and got the wrong dir. I think it's because validateFileExists() doesn't take --root into account, which is added when the command is executed through SSH.

@weitzman
Copy link
Member

weitzman commented Nov 2, 2017

The cwd should already be Drupal root by the time @validate-file-exists starts doing its work. See

chdir($drupal_root);
.

@greg-1-anderson
Copy link
Member

Relative file paths used in options (e.g. --file) should be evaluated relative to the cwd that was set prior to running Drush, not relative to the Drupal root, which is set as described above.

The original cwd is available via the key env.cwd in config. @validate-file-exists should probably convert relative paths to absolute from env.cwd before testing (and set the $option to ensure consistency).

Relative paths for remote commands are perhaps a dubious proposition. Logically, these are relative to the $HOME directory of the remote user.

@greg-1-anderson
Copy link
Member

Drush 8 and earlier sets the cwd for remote commands to the Drupal root, so I suppose we should maintain that behavior.

@weitzman
Copy link
Member

weitzman commented Nov 2, 2017

Its a problem in SqlCommands. Fixing now ...

@weitzman weitzman self-assigned this Nov 2, 2017
@greg-1-anderson
Copy link
Member

Maybe it would be helpful to cwd in preflight?

@weitzman
Copy link
Member

weitzman commented Nov 2, 2017

Fixed in #3135. We decided not to move the chdir() to Preflight.

@weitzman weitzman closed this as completed Nov 2, 2017
@gaelg
Copy link
Contributor Author

gaelg commented Nov 9, 2017

Thank you, it works! :)

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

3 participants