lando / php

The Official Lando PHP plugin.
https://docs.lando.dev/php
GNU General Public License v3.0
16 stars 16 forks source link

Windows10 Pro lando drush issue #9

Closed UrielNicolas closed 2 months ago

UrielNicolas commented 4 years ago

Basically any other task or issue should go here. Try to frame it as a user story if it makes sense. I'm trying to make Lando work in Windows10 I was able to install lando, it actually works, but I have issues with Drush

OCI runtime exec failed: exec failed: container_linux.go:346: starting container process caused "exec format error": unknown

This is my .lando.yml name: sitename recipe: pantheon config: webroot: web framework: drupal8 site: sitename id: ID tooling: local-load-db: service: appserver description: Load database cmd: /app/local/import.sh level: app

I'm not sure what the issue is, and I've been trying to find out what is happening, but I have no idea.

I also have issues at running our local scripts, but unless Drush works first, it's futile.

TMFEspresso commented 4 years ago

The OCI runtime exec errors are more Docker erring than Lando failing.

Try restarting Docker - sometimes Docker just glitches out and can cause weird errors.

My other guess is this: https://www.lewuathe.com/exec-format-error-in-docker-container.html

UrielNicolas commented 4 years ago

I will check this and let you know. This is working 100% in ubuntu, so I know for sure the problem is in Windows10 and some of the setup I made.

UrielNicolas commented 4 years ago

Ok, not working. I did some testing inside lando ssh and it seems drush it's not working there either, I get the following error /usr/bin/env: 'php\r': No such file or directory

But I do have php www-data@fdaf4ce1ecab:/app/vendor/drush/drush$ php --version PHP 7.3.13 (cli) (built: Dec 28 2019 21:49:35) ( NTS ) Copyright (c) 1997-2018 The PHP Group Zend Engine v3.3.13, Copyright (c) 1998-2018 Zend Technologies with Zend OPcache v7.3.13, Copyright (c) 1999-2018, by Zend Technologies

Anyone knows where to go from there?

idpokute commented 4 years ago

I have the same issue. I use windows 10 pro.

UrielNicolas commented 4 years ago

I have the same issue. I use windows 10 pro.

I tried Windows Linux Subsystem and it's not working either. I'm starting to think you need to d something different when building a lando for windows

uberhacker commented 4 years ago

@UrielNicolas @TMFEspresso @idpokute: In what terminal app did you notice this error? I found out if I ran dos2unix on the files causing the errors in Git Bash, it fixed the issue. It appears certain files that have CRLF instead of LF endings can cause this issue.

UrielNicolas commented 4 years ago

I'm runing this in PowerShell or CommandPrompt, a lando environment for Pantheon

When starting lando I get this error /app/vendor/bin/drush: 1: /app/vendor/bin/drush: ../drush/drush/drush: not found

any command, I get this OCI runtime exec failed: exec failed: container_linux.go:346: starting container process caused "no such file or directory": unknown

notserk commented 4 years ago

Any updates on this issue? I'm still dealing with this issue.

notserk commented 4 years ago

I'm also running on windows 10 pro. It seems drush doesn't get loaded during the bootstrap process: Getting CA Private Key /usr/share/ca-certificates/lndo.site.pem not found... copying /lando/certs/lndo.site.pem over % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 599 100 599 0 0 3477 0 --:--:-- --:--:-- --:--:-- 3482 100 4673k 100 4673k 0 0 7391k 0 --:--:-- --:--:-- --:--:-- 7391k /app/vendor/bin/drush: 1: /app/vendor/bin/drush: ../drush/drush/drush: not found error: Looks like one of your build steps failed! with Error at C:\snapshot\lando\build\cli\lib\shell.js From previous event: at Shell.sh (C:\snapshot\lando\build\cli\lib\shell.js) at Object.dc (C:\snapshot\lando\build\cli\lib\bootstrap.js) at compose (C:\snapshot\lando\build\cli\lib\bootstrap.js) From previous event: at C:\snapshot\lando\build\cli\lib\router.js at processImmediate (internal/timers.js:439:21) From previous event: at Object.run (C:\snapshot\lando\build\cli\lib\router.js) at run (C:\snapshot\lando\build\cli\lib\engine.js) at C:\snapshot\lando\build\cli\lib\router.js

Asterovim commented 4 years ago

https://github.com/lando/lando/issues/2085 I think is a related problem. I have the same error with lando drush.

OCI runtime exec failed: exec failed: container_linux.go:346: starting container process caused "function not implemented": unknown

Opswatch commented 4 years ago

Same issue as me, Windows 10 pro, I tried both the docker release that comes with v3.0.0-rrc.3 as well as docker 2.1.0.5 just to be sure, I do have wsl installed going to try without it.

Did some further testing and interesting enough starting the the drupal recipe in empty folder builds drush properly it only seems to error out if there is drupal code in the folder.

jan-di commented 4 years ago

I'm runing this in PowerShell or CommandPrompt, a lando environment for Pantheon

When starting lando I get this error /app/vendor/bin/drush: 1: /app/vendor/bin/drush: ../drush/drush/drush: not found

any command, I get this OCI runtime exec failed: exec failed: container_linux.go:346: starting container process caused "no such file or directory": unknown

Maybe it helps someone: I had a similar problem when working on windows. Everytime when I start lando the "build_as_root" step failed with the error message from @UrielNicolas comment. The problem was indeed, that the git on windows checked out all the files with CRLF file endings, including the shell scripts. When those shell scripts are executed in the appserver container, linux can't find the shell defined in the shebang (because it tries /bin/sh\r instead of /bin/sh).

So the solution for me was to setup git that it always check out file endings as-is: $ git config --global core.autocrlf input

https://git-scm.com/book/en/v2/Customizing-Git-Git-Configuration#_formatting_and_whitespace

Opswatch commented 4 years ago

Unfortunately even with "git config --global core.autocrlf input" still getting the same error :(

Tried several different ways of specifying the drush location and even using global drush, it would either give the initial error or docker errors - https://docs.lando.dev/config/drupal8.html#configuration / the same site repo works fine with no modifications to the drupal8 recipe on osx

Did some more digging it seems to be related to the drupal vendor/bin/drush file, deleting it and doing a lando rebuild gets it working, the repos work fine on the osx version.

Spoke too soon doing the above lets it rebuild the container but drush is still broken i had to delete the bin folder then do a lando composer install and lando rebuild and that got it fully working.

pirog commented 4 years ago

I am not able to replicate any of the above posted issues using the following:

system

OS: Windows 10 Pro
Docker Desktop: 2.2.0.5
Lando: 3.0.0-rrc.7
Recipe: Pantheon with vanilla latest Drupal 8

pantheon.yml

# Put overrides to your pantheon.upstream.yml file here.
# For more information, see: https://pantheon.io/docs/pantheon-yml/
api_version: 1
drush_version: 10
php_version: 7.3

landofile

name: landobot-drupal8
recipe: pantheon
config:
  framework: drupal8
  site: landobot-drupal8
  id: 0831109d-10e9-426a-845a-e8396554acfa

My suspicion is this thread may have a few distinct issues but i was not able to repro any of them.

flyke commented 4 years ago

I just got this error on my windows 10 machine after rebuilding a project after updating lando to 3.0.5. These steps fixed it for me:

My .lando.yml file:

name: myproject
recipe: drupal8

config:
  webroot: web
  drush: ^10
  php: 7.4
  via: apache:2.4
  database: mysql:5.7
  xdebug: false

# Get nice URL's
proxy:
  mailhog:
    - mail.myproject.lndo.site
  pma:
    - pma.myproject.lndo.site

services:
  # Automatically composer install before my app starts - for site local Drush
  appserver:
    build:
      - composer install
    config:
      php: scripts/lando.php.ini

  # MailHog
  mailhog:
    type: mailhog
    hogfrom:
      - appserver

  # PhpMyAdmin
  pma:
    type: phpmyadmin
    hosts:
      - database
tmsss commented 4 years ago

I'm afraid I've bumped into the same error on the drupal 9 recipe and @flyke's solution didn't worked for me. The site-local drush instalation documentation here also didn't work.

Does anyone have further suggestions? An example of a drupal 9 lando recipe for windows 10 would be of great value. Thanks!

tmsss commented 4 years ago

I've experimented with the tooling configuration and looks like the traditional path in /app/vendor/bin/drush doesn't work on Windows 10. This was what fixed it for me:

name: myproject
recipe: drupal9
config:
  webroot: ./web
  drush: ^10
  xdebug: true
  tooling:
    drush:
      service: appserver  
      cmd: php /app/vendor/drush/drush/drush
Asterovim commented 4 years ago

I can also suggest to use the Docker with WSL2. Lando is very better with wsl2 (more speed, more stable, no erreur of permission and many more..).

web-assistant commented 4 years ago

I'm using Docker Desktop with WSL2. I did both steps:

And this fixed the error for me. Thank you 😊

flyke commented 4 years ago

When it dod not work for me in another project, I had to add drush to the tooling section too. Since I have my vendor folder in the root of my project, this was the correct tooling section to get drush working for me:

tooling:
  drush:
    service: appserver
    cmd:
      - "vendor/drush/drush/drush"

The nice thing about this is that these changes are immediate. No need to lando restart or lando rebuild, the drush command works instantly after saving the modified .lando.yml file

Chaquea commented 4 years ago

Using a custom lando file for drupal 8, where the vendor folder is placed under "docroot", this worked for me in windows 10 and Docker Desktop with WSL2,as https://github.com/lando/lando/issues/1949#issuecomment-668538569 describes, didnt had to rebuild or restart lando for it to work.

tooling:
  drush:
    service: appserver
    cmd:
      - php "vendor/drush/drush/drush"
UrielNicolas commented 4 years ago

Using WSL2 I was able to use lando. I also had to add something to start docker when I open WSL2

stale[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions and please check out this if you are wondering why we auto close issues.

flyke commented 3 years ago

I had this a couple more times where I got this error on a custom lando command: /app/vendor/bin/drush: 1: /app/vendor/bin/drush: ../drush/drush/drush: not found Even after adding the tooling drush section into the .lando.yml file.

This usually happens on a (git) project where both a developer with a windows machine and a developer with a Mac machine are working on. The working solution is this for your windows machine:

poindexterous commented 2 years ago

I'm struggling with this also, we're currently in the middle of our drupal 8 to drupal 9 upgrade; we're a cross-platform team (some use macs, some use PCs with W10 pro) so we have no choice but to try and get this to work. Nuking drush (both the drush vendor folder and the drush bin file) and reinstalling it with composer then rebuilding Lando still doesn't seem to fix it. The repo already contains a gitconfig file (I believe this was added to drupal core at some point last year) that takes care of the line ending conversion between unix and windows, but we don't want to necessarily mess with that to get these files to play nice with lando since the last thing I'd want is for a PC line ending file not getting properly converted in a commit.

I'm still experimenting, if I make a breakthrough I will share my findings here.

permanaj commented 2 years ago

I have similar usecase @poindexterous , I currently solve this by adding

windrush:
    service: appserver
    description: Run drush in Windows host OS
    cmd: php /app/vendor/drush/drush/drush

to tooling section, and then run lando windrush cr on Windows OS and lando drush cr in MacOS. Project currently use lightning distribution. And I have not try drush nuke.

poindexterous commented 2 years ago

My drupal project uses core-recommended, and is an existing drupal 8 project we're in the process of upgrading to d9. Not sure if it makes a difference but I wanted to mention it.

Thank you @permanaj , I was fiddling around with the landofile and your suggestion helped. I was still having some errors with drush after that (with rsync & sql-sync) as well as ongoing problems with the composer symlinks. While running 'composer install' did help solve the problem for both, I was left with a ton of CRLF changes in the repo, and the build took a really long time! This all made me wonder if 'composer install' might be overkill since my issues only seemed to come from drush and composer. So I tried to create a landofile with more targeted build steps and I symlinked to where the container's composer install lived. Here's my temporary workaround:


name: {mysite}
recipe: drupal9
config:
  webroot: ./docroot
  php: '7.4'
  drush: ^10
  composer_version: '1.8.6'

tooling:
  drush:
    service: appserver
    # Enable cmd line below for Windows, disable for MacOS.
    cmd: php /app/vendor/drush/drush/drush
    env:
      DRUSH_OPTIONS_URI: {mysite url}

services:
  appserver:
    xdebug: true
   # Enable build steps for Windows only, disable MacOs.
    build:
      - ln -sf /usr/local/bin/composer /app/vendor/bin/composer
      - rm -rf vendor/drush
      - rm vendor/bin/drush
      # Change to match whatever drush version you want.
      - composer require drush/drush:10.6.0 

I also have some additional build steps that I left out since they may be unique to my use case. They ignore local changes to drush and composer that are just reside from the build process and we don't necessarily want to commit them to the repo, while reverting unwanted changes to .htaccess in case the scaffolding tries to revert back to it's boilerplate version.

simonmerrell commented 2 years ago

Many thanks to the contributors to this thread. I'm having a very similar problem with Drush. I'm using Win10 + WSL2 + Ubuntu 18.04 and working on a Drupal 9 project.

Thanks to your suggestions, I have a working Drush command now, and my recipe is:

name: project recipe: drupal9 config: php: '8.0' webroot: project/web

tooling: drush: service: appserver cmd: php "project/web/vendor/drush/drush/drush" env: DRUSH_OPTIONS_URI: "https://project.lndo.site"

I assume this cmd will need to be removed for the Mac OS collaborators on my project.

UnsettlingTrend commented 1 year ago

Lando was working just fine with Drush.... until it wasn't. For some reason, just adding the php to php 'app/vendor/bin/drush' did the trick on Win10.

zuernBernhard commented 1 year ago

Yes same here too after upgrading Lando and docker

works:

lando php /app/vendor/bin/drush cr

does not work:

$ lando drush cr OCI runtime exec failed: exec failed: unable to start container process: exec: "/app/vendor/bin/drush": permission denied: unknown

zuernBernhard commented 1 year ago

Update: I could make it work again by deleting everything which was installed by composer and do a

lando composer install

after that

AaronFeledy commented 2 months ago

Since this ticket was opened, there have been a number of improvements in handling the various scenarios mentioned in this thread. Given that it has been 18 months without any new comments here, I'm going to close this out and assume that Lando is now working as expected for everyone. If there is anything that still needs addressing, please open a new issue.