Wondering if anyone knows why some Drush commands (with file parameters) only run from the docroot and won't run from the project/composer root?

Commands such as drush sql-query and drush locale-import are among these.

For example, with standard Drupal folder structure:

/ (composer root)

  • composer.json
  • vendor
  • translations
    • translations.fr.po
  • web (docroot)

running from composer root:

  • vendor/bin/drush locale-import fr translations/translations.fr.po

gives file not found error. Even using ./translations/translations.fr.po gives same error

but going to docroot and running:

  • ../vendor/bin/drush ../translations/translation.fr.po

works fine.

Our deploy scripts always run composer, drush and other commands from the composer root folder. So a bit of a pain to have to cd /web and then cd .. for these couple "special" Drush commands. Guessing there must be something I am doing wrong.

  • 2
    IIRC Drush commands tend to run with the web root (not execution path) as the working directory - does vendor/bin/drush locale-import fr ../translations/translations.fr.po from the project root work?
    – Clive
    Commented Jan 17, 2022 at 22:16
  • It might depend a on the version of Drush and the composer.json template you are using. Is the web root defined in composer.json? What version of Drush?
    – leymannx
    Commented Jan 17, 2022 at 23:25
  • But in the end I think it's always safer to execute Drush commands from within the webroot.
    – leymannx
    Commented Jan 17, 2022 at 23:31
  • 1
    @Clive, yes, that's the answer. I can run in project root but Drush still thinks of things as from docroot. Excellent. Thank you.
    – liquidcms
    Commented Jan 19, 2022 at 20:53
  • Not sure how to mark a comment as the answer :(
    – liquidcms
    Commented Jan 19, 2022 at 20:54

2 Answers 2


If you use a drush alias, it shouldn’t matter where you run the command from e.g

drush @site some-command

The webroot is specified in the alias.

More info https://www.drush.org/latest/site-aliases/

  • That's an alias to the site url. It won't have any impact on Drush not handling path to file arguments correctly.
    – liquidcms
    Commented Jan 19, 2022 at 20:51
  • @liquidcms The drush alias contains various settings including the webroot directory specified in the root setting eg “root: /other/path/to/live/drupal” Commented Jan 20, 2022 at 6:11

Clive didn't post as an answer so I will just copy here:

Drush commands run as if from the web root (not execution path) as the working directory. So even though running command from the project root; argument paths have to be entered as if coming from the web root.

vendor/bin/drush locale-import fr ../translations/translations.fr.po

  • from the project root

David's answer would also work if you were using aliases (which I am not).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.