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

Windows10 Pro lando drush issue #9

Open
UrielNicolas opened this issue Jan 23, 2020 · 31 comments
Open

Windows10 Pro lando drush issue #9

UrielNicolas opened this issue Jan 23, 2020 · 31 comments

Comments

@UrielNicolas
Copy link

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
Copy link

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
Copy link
Author

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
Copy link
Author

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
Copy link

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

@UrielNicolas
Copy link
Author

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
Copy link

@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
Copy link
Author

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
Copy link

notserk commented Mar 16, 2020

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

@notserk
Copy link

notserk commented Mar 16, 2020

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
Copy link

lando/lando#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
Copy link

Opswatch commented Apr 7, 2020

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
Copy link

jan-di commented Apr 17, 2020

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
Copy link

Opswatch commented Apr 22, 2020

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 pirog assigned smutlord and pirog and unassigned smutlord Apr 25, 2020
@pirog
Copy link
Sponsor Member

pirog commented May 4, 2020

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.

@pirog pirog removed their assignment May 5, 2020
@flyke
Copy link

flyke commented Jun 15, 2020

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:

  • delete vendor/drush folder
  • restart docker
  • lando rebuild
    Hope this helps someone else with the same problem someday.

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
Copy link

tmsss commented Jul 1, 2020

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
Copy link

tmsss commented Jul 1, 2020

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
Copy link

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
Copy link

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

And this fixed the error for me. Thank you 😊

@flyke
Copy link

flyke commented Aug 4, 2020

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
Copy link

Chaquea commented Sep 9, 2020

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
Copy link
Author

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

@stale
Copy link

stale bot commented Apr 27, 2021

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
Copy link

flyke commented Jun 2, 2021

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:

  • delete vendor/bin/drush file
  • delete vendor/drush folder
  • run a composer install. I am assuming that you have added drush for your project via composer. This wil re-install drush
  • Now the error is fixed and you can run your lando command successfully.

@poindexterous
Copy link

poindexterous commented Oct 13, 2021

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
Copy link

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
Copy link

poindexterous commented Oct 15, 2021

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.

@rtfm-47 rtfm-47 transferred this issue from lando/lando Dec 21, 2021
@simonmerrell
Copy link

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
Copy link

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
Copy link

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
Copy link

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

lando composer install

after that

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

No branches or pull requests