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

Pantheon D8 sh: 1: ssh: not found on Lando pull or lando drush @pantheon.site.env with local drush #1315

Closed
aaron-capellic opened this Issue Nov 27, 2018 · 20 comments

Comments

Projects
None yet
@aaron-capellic
Copy link

aaron-capellic commented Nov 27, 2018

Bug Report

Tell us about your setup
Lando: v3.0.0-rc.1 ubuntu 16.04

Tell us about your .lando.yml

name: olh
recipe: pantheon
# Uncomment and restart to enable PHPMyAdmin
proxy:
  pma:
    - pma.olh.lndo.site
config:
  framework: drupal8
  site: olh
  id: xxxxxx
  web: web

compose:
  - docker-compose.yml

events:
  post-pull:
    - appserver: cd $LANDO_WEBROOT && drush cc drush && drush sitesan

  post-db-import:
    - appserver: cd $LANDO_WEBROOT && drush cc drush && drush sitesan

services:
  appserver:
    xdebug: true
    overrides:
      services:
        environment:
          BEHAT_PARAMS: >-
            {"extensions" : {"Behat\\MinkExtension" : {"base_url" :
            "http://nginx/", "files_path" : "/app/testing/features/fixtures/"}, "Drupal\\DrupalExtension" : {"drush" :   {
            "root":  "/app/web" }}}}
          CI_ENV: ci-${CIRCLE_BUILD_NUM}
          PANTHEON_SITE: ${TERMINUS_SITE}
          CIRCLE_BRANCH: ${CIRCLE_BRANCH}
          CIRCLE_USERNAME: ${CIRCLE_USERNAME}
          GIT_EMAIL: ${GIT_EMAIL}
# Uncomment and restart to enable PHPMyAdmin
  pma:
    type: phpmyadmin
    hosts:
      - database
tooling:
  behat:
    service: appserver
    cmd: "/app/vendor/bin/behat --config=/app/tests/behat.yml"


docker-compose.yml

version: '3'

services:
  chromedriver:
    image: robcherry/docker-chromedriver:latest
    volumes:
      - ${LANDO_APP_ROOT}/:/app/
      - /dev/shm:/dev/shm # See https://github.com/elgalu/docker-selenium/issues/20#issuecomment-325090454
    expose:
      - "4444"
    environment:
      CHROMEDRIVER_WHITELISTED_IPS: ""
      CHROMEDRIVER_URL_BASE: "/wd/hub"
    security_opt:
      - seccomp:unconfined

pantheon.yml

api_version: 1
web_docroot: true
php_version: 7.2
workflows:
  deploy_product:
    after:
      - type: webphp
        description: Sanitize databse
        script: private/scripts/site_sanitize.php
      -
        type: webphp
        description: 'Run composer prepare-for-pantheon'
        script: private/scripts/deploy_product/prepare-for-pantheon.php
      -
        type: webphp
        description: 'Run composer install & drupal-scaffold'
        script: private/scripts/deploy_product/composer-install.php

  clone_database:
    after:
      - type: webphp
        description: Sanitize database
        script: private/scripts/site_sanitize.php

Tell us about the command you were running

lando drush @pantheon.site.env status

This returns sh: 1: ssh: not found

with -vvvv

Loaded alias @pantheon.olh.dev from file                                [notice]
/var/www/.drush/pantheon.aliases.drushrc.php
Begin redispatch via drush_invoke_process().                            [notice]
Calling proc_open(ssh -p 2222 -o "AddressFamily inet" dev.xxxxxx@appserver.dev.xxxxxx.drush.in 'drush  --root=/app/web --uri=https://uca.lndo.site --verbose --db-url='\''mysql://pantheon:xxxxx@dbserver.dev.xxxxx.drush.in:17764/pantheon'\''  core-status 2>&1' 2>&1);
sh: 1: ssh: not found
End redispatch via drush_invoke_process().         

lando pull returns:

Detected that olh is a drupal8 site
Checking for /lando/keys/pantheon.lando.id_rsa
Destroying all current tables in database... 
Downloading drush aliases...
 [notice] Aliases file written to ~/.drush/pantheon.aliases.drushrc.php.
@pantheon.olh.dev
Clearing remote cache to shrink db size
sh: 1: ssh: not found
 [notice] OK >> dev-olh.pantheonsite.io responded
Pulling database from dev...
  22 B 0:00:00 [36.1 B/s] [<=>                                                 ]
ERROR 1064 (42000) at line 1: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'sh: 1: ssh: not found' at line 1

Pull complete!

Tell us generally about your bug

If I run lando ssh, and then run ssh -p 2222 -o "AddressFamily inet" dev.xxxxxx@appserver.dev.xxxxxx.drush.in 'drush --root=/app/web --uri=https://uca.lndo.site --verbose --db-url='\''mysql://pantheon:xxxxx@dbserver.dev.xxxxx.drush.in:17764/pantheon'\'' core-status 2>&1' 2>&1 the command succeeds, so it looks like something is happening when lando passes in the commandj.

This bug breaks lando pull, which breaks our CI process.

@aaron-capellic aaron-capellic changed the title Pantheon D8 sh: 1: ssh: not found on Lando pull or lando drush @pantheon.site.env Pantheon D8 sh: 1: ssh: not found on Lando pull or lando drush @pantheon.site.env with local drush Nov 27, 2018

@aaron-capellic

This comment has been minimized.

Copy link
Author

aaron-capellic commented Nov 27, 2018

When using global drush ssh works as expected.

config:
  drush: global:8.1.17
@jacine

This comment has been minimized.

Copy link

jacine commented Nov 27, 2018

I'm having a similar issue here. I've reinstalled Lando and Docker entirely, deleting .lando, resetting Docker, with multiple versions, multiple times, and always end up with the same issue. Currently I have Lando v3.0.0-rc.1, with Docker 18.06.1-ce-mac73 (26764) installed via the dmg, on OS X 10.14.1 (Mojave).

And the above suggestion to add drush: global:8.1.17 config doesn't help.

With lando pull, the files and code steps complete successfully. The database fails with the error:

ERROR 1064 (42000) at line 1: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'sh: 1: ssh: not found' at line 1

Manually pulling the database with documented commands via terminus and db-import work, but only drush uli and drush cr seem to work. Any other commands that involve bootstrapping, such as drush cex complain about not being able to bootstrap Drupal.

Command config-export needs a higher bootstrap level to run - you        [error]
will need to invoke drush from a more functional Drupal environment
to run this command.
...

This is the status it reports:

Drush was attempting to connect to:
 Drupal version         :  8.6.2
 Site URI               :  http://default
 Database driver        :  mysql
 Database hostname      :  database
 Database port          :  3306
 Database username      :  pantheon
 Database name          :  pantheon
 PHP executable         :  /usr/local/bin/php
 PHP configuration      :
 PHP OS                 :  Linux
 Drush script           :  /app/vendor/drush/drush/drush.php
 Drush version          :  8.1.17
 Drush temp directory   :  /tmp
 Drush configuration    :
 Drush alias files      :
 Drupal root            :  /app/web
 Drupal Settings File   :  sites/default/settings.php
 Site path              :  sites/default
 Sync config path       :  /app/config

So, there is no bootstrap, database connection, php config, or drush aliases. This is my current Lando file.

name: [redacted]
recipe: pantheon
config:
  framework: drupal8
  site: [redacted]
  id: [redacted]
  webroot: web
  xdebug: true
  drush: global:8.1.17 

I have also tried this without:

config:
  xdebug: true
  drush: global:8.1.17 

And with:

tooling:
  drush:
    cmd:
      - "drush --root=/app/web --uri=https://[redacted].lndo.site"
@aaron-capellic

This comment has been minimized.

Copy link
Author

aaron-capellic commented Nov 27, 2018

@jacine If drush is installed locally with composer, you'll need to run
composer remove drush/drush in addition to adding the global config.

@pirog

This comment has been minimized.

Copy link
Member

pirog commented Nov 27, 2018

@aaron-capellic @jacine ive seen different flavors of this "binary not found" issue pop up over the last few days and i suspect it has to do with SOMETHING not playing nice with the PATH. Could you guys try running lando ssh appserver -c "env | grep PATH" and pasting in the output?

@aaron-capellic

This comment has been minimized.

Copy link
Author

aaron-capellic commented Nov 27, 2018

$ lando ssh appserver -c "env | grep PATH"
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/var/www/.composer/vendor/bin
@pirog

This comment has been minimized.

Copy link
Member

pirog commented Nov 27, 2018

hmmm ok yah that looks about what id expect :/

@jacine

This comment has been minimized.

Copy link

jacine commented Nov 27, 2018

@jacine If drush is installed locally with composer, you'll need to run
composer remove drush/drush in addition to adding the global config.

Ah, yes that makes sense. Thank you! I did not do this, and won't. Don't want to mess anyone else on the team up, so I'm working in MAMP for now.

Sure @pirog, mine is the same:

 $ lando ssh appserver -c "env | grep PATH"
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/var/www/.composer/vendor/bin
@cainaru

This comment has been minimized.

Copy link

cainaru commented Nov 27, 2018

@pirog, I'm having same errors as @jacine. Running lando ssh appserver -c "env | grep PATH" gives me the following:

$ lando ssh appserver -c "env | grep PATH"
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/var/www/.composer/vendor/bin
@brysonca

This comment has been minimized.

Copy link

brysonca commented Nov 27, 2018

This error "sh: 1: ssh: not found" shows whenever drush aliases are used. Simply running lando drush @pantheon.site.env will throw it. Aliases files download automatically from pantheon using terminus appear to be in the right correct format. I did notice that Terminus got an update to 1.9.0. Did drush get similar treatment in some latest updates?

@pirog

This comment has been minimized.

Copy link
Member

pirog commented Nov 28, 2018

So i think the issue here has to do with some breaking changes in newer versions of Drush 8.

While we don't think this is fundamentally an issue with Lando, we've got some better drush management handling we plan to roll out in the next release. in the meantime the workaround that worked for me was to update to the latest drush 9 via composer and set

tooling:
  drush:
    cmd: /app/vendor/bin/drush

In my .lando.yml

I've also heard that just removing the composer installed drush (or just locking it down explicitly to 8.1.16) and using landos globally installed one seems to do the trick as a temp workaround

brysonca pushed a commit to cwidahocc/d8cwi that referenced this issue Nov 28, 2018

@pirog pirog added this to the RC1 milestone Nov 28, 2018

@pirog pirog self-assigned this Nov 28, 2018

@jacine

This comment has been minimized.

Copy link

jacine commented Nov 29, 2018

I went back to this yesterday, as other team members were also having issues, and I got it working...

  • Drush 9: Using Drush 9 does solve the problem... However, it breaks Behat tests in CircleCI with Unable to access the response before visiting a page (Behat\Mink\Exception\DriverException). I went down a rabbit hole trying to fix this, and was ultimately unsuccessful. I believe it has something do with backwards incompatible changes in Behat, which drupal-extension dropped support for, and there appear to be dependency conflicts somewhere along the line (IIRC with Symfony versions) that prevent downgrading.

  • Global Drush 8.1.16: Using global Drush DOES work. At first it didn't, I think because I had tried drush: global:8.1.17, but after changing that and rebuilding it is working for me now. Below is the current Lando config, which is fully working again (locally and with tests on CI) in case it helps anyone else:

name: [redacted]
recipe: pantheon
config:
  framework: drupal8
  site: [redacted]
  id: [redacted]
  webroot: web
  php: '7.2'
  xdebug: true
  drush: global:8.1.16

Thanks for your help @pirog and @aaron-capellic! 👏

@ccharlton

This comment has been minimized.

Copy link
Contributor

ccharlton commented Nov 30, 2018

@jacine your changes worked for me.

@ccjjmartin

This comment has been minimized.

Copy link
Contributor

ccjjmartin commented Nov 30, 2018

I ran into this too I don't have a bin directory and I have a docroot so my solution looked liked this:

cmd: /app/vendor/drush/drush/drush --root=/app/docroot

brysonca pushed a commit to cwidahocc/d8cwi that referenced this issue Dec 2, 2018

@shaal

This comment has been minimized.

Copy link
Contributor

shaal commented Dec 6, 2018

#1317

@jacine to use drush 9.5 I added these lines to lando.yml -

tooling:
  drush:
    cmd:
      - /app/vendor/bin/drush
@aangelinsf

This comment has been minimized.

Copy link

aangelinsf commented Dec 10, 2018

I can report that upgrading to Drush 9 and using the following worked for me:

tooling:
  drush:
    cmd: /app/vendor/bin/drush
@kclarkson

This comment has been minimized.

Copy link

kclarkson commented Dec 15, 2018

Upgrading to drush 9 and adding the tooling configuration worked for me as well. I also had to do a lando rebuild for it to work.

tooling:
  drush:
    cmd: /app/vendor/bin/drush
@nterbogt

This comment has been minimized.

Copy link

nterbogt commented Dec 18, 2018

A bit more info on this issue that might help.

I'm not entirely convinced this was due to an update in drush. I've got a composer lock that tells me I'm installing 8.1.17 and that hasn't changed in my builds since 2018-06-01. This only broke for me in the last day or two when I downloaded the latest pantheon-appserver and did a rebuild.

@krisrobinson

This comment has been minimized.

Copy link

krisrobinson commented Dec 30, 2018

Also having this problem, as @nterbogt described, after updating lando to RC1 and downloading latest pantheon-appserver.

In the end the issue was most likely drush, and was solved by following steps on this issue:

#1318 (comment)

@tmountjr

This comment has been minimized.

Copy link

tmountjr commented Jan 10, 2019

Worth noting here, too, that if your composer.json includes drush, your drush launcher will, by default, grab that, instead of the one installed globally via .lando.yml, which means that if you specify both you might end up banging your head against a wall. The workarounds are either to run lando composer remove drush/drush or to specify in the tooling section that you want to use the global one, not the project one.

@pirog

This comment has been minimized.

Copy link
Member

pirog commented Jan 12, 2019

We've implemented some smarter handling on the Lando end to help mitigate this and will be rolling it out in RC2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment