0

I run into an issue that the use of an alias returns correct values, but without alias or from remote, I miss the DB connection. Furthermore, the root directory is wrong. The missing DB connection prevents a drush sql:sync run.

Alias file:

$drush sa
'@self.dev':
  root: /var/www/html/xyz
  uri: 'https://www.abcdef.com'
  ssh:
    options: '-i xyz.pem'
  paths:
    drush-script: /home/ubuntu/vendor/bin/drush
    files: themes
  command:
    core:
      rsync:
        options:
          mode: rlptz

running drush status somewhere:

$ drush st
PHP binary    : /usr/bin/php7.4
PHP config    : /etc/php/7.4/cli/php.ini
PHP OS        : Linux
Drush script  : /home/ubuntu/vendor/drush/drush/drush
Drush version : 10.6.2
Drush temp    : /tmp
Drush configs : /home/ubuntu/.drush/drush.yml
                /home/ubuntu/vendor/drush/drush/drush.yml

running drush status with alias:

$ drush @dev st
Drupal version   : 9.4.5
Site URI         : https://www.abcdef.com
DB driver        : mysql
DB hostname      : 127.0.0.1
DB port          : 3306
DB username      : qwertzy
DB name          : drupal
Database         : Connected
Drupal bootstrap : Successful
Default theme    : xyz
Admin theme      : seven
PHP binary       : /usr/bin/php7.4
PHP config       : /etc/php/7.4/cli/php.ini
PHP OS           : Linux
Drush script     : /var/www/html/xyz/vendor/drush/drush/drush
Drush version    : 10.6.2
Drush temp       : /tmp
Drush configs    : /home/ubuntu/.drush/drush.yml
                   /var/www/html/xyz/vendor/drush/drush/drush.yml
Install profile  : standard
Drupal root      : /var/www/html/xyz/web
Site path        : sites/default
Files, Public    : sites/default/files
Files, Private   : /var/private
Files, Temp      : /tmp

running drush status in the drupal root: ! Wrong drupal root returned

cd /var/www/html/xyz
$ drush st
PHP binary    : /usr/bin/php7.4
PHP config    : /etc/php/7.4/cli/php.ini
PHP OS        : Linux
Drush script  : /home/ubuntu/vendor/drush/drush/drush
Drush version : 10.6.2
Drush temp    : /tmp
Drush configs : /home/ubuntu/.drush/drush.yml
                /home/ubuntu/vendor/drush/drush/drush.yml
Drupal root   : /var/www/html/xyz/web/web

called from remote with alias: ! Again wrong drupal root returned

ubuntu@ip-172-26-13-167 ~ $ drush @dev st
PHP binary    : /usr/bin/php7.4
PHP config    : /etc/php/7.4/cli/php.ini
PHP OS        : Linux
Drush script  : /home/ubuntu/vendor/bin/drush
Drush version : 10.6.2
Drush temp    : /tmp
Drush configs : /home/ubuntu/.drush/drush.yml
                /home/ubuntu/vendor/drush/drush/drush.yml
Drupal root   : /var/www/html/xyz/web/web
Connection to 172.26.10.26 closed.

Any advice appreciated how to fix this.

5
  • 2
    Try vendor/bin/drush from Drupal root. It seems like you have a problem with the globally installed Drush, it doesn't delegate to the locally installed Drush. Use the Drush launcher instead and update to the current Drush version, your version is no longer supported.
    – 4uk4
    Commented Sep 29, 2022 at 7:06
  • Calling it via vendor/bin/drush doesn't make a difference. Drush launcher is installed. I ask myself why only with using @alias the full result is returned.
    – Micha
    Commented Sep 29, 2022 at 11:39
  • 2
    My comment is based on the drush status output Drush script : /home/ubuntu/vendor/drush/drush/drush after cd /var/www/html/xyz.
    – 4uk4
    Commented Sep 29, 2022 at 11:45
  • Or maybe make it more easy: if I'm using drush dd the following will return /var/www/html/xyz/web/web but if I run a drush @dev st the drupal root is Drupal root : /var/www/html/xyz/web
    – Micha
    Commented Sep 29, 2022 at 11:53
  • and if I'm in the root directory the same is returned web/web... ubuntu@ip-172-26-10-26 /var/www/html/xyz $ ~/vendor/bin/drush dd /var/www/html/xyz/web/web
    – Micha
    Commented Sep 29, 2022 at 12:00

1 Answer 1

0

I've commented because there are some things in your installation that don't add up. But the comments lead to nowhere so I try to make it more clear in an answer.

In a comment you say:

Drush launcher is installed.

but then "running drush status somewhere" should result in:

The Drush launcher could not find a Drupal site to operate on. Please do *one* of the following:
  - Navigate to any where within your Drupal project and try again.
  - Add --root=/path/to/drupal so Drush knows where your site is located.

So the question is, what is this globally installed script which runs when you are in a Drupal root directory

/home/ubuntu/vendor/drush/drush/drush

when it is not the Drush Launcher?

1
  • ok let me verify this. Just brought up a new environment using drush 11 and launcher. Maybe for some reason the existing setup isn't stable any longer.
    – Micha
    Commented Sep 29, 2022 at 15:42

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.