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

Lando version beta.29 and above does not find drush when running lando drush status #74

Closed
dandinu opened this issue Dec 12, 2017 · 17 comments

Comments

@dandinu
Copy link

dandinu commented Dec 12, 2017

Hi,

There is a problem with the latest versions of Lando (beta.29 through beta.31). When I run lando drush status I get:

The Drush launcher could not find a local Drush in your Drupal site.
Please add Drush with Composer to your project.
Run 'cd "/app" && composer require drush/drush'

image

The issue does not replicate on beta.28. It works without any issues there and I have no idea why.

Steps to replicate:

  1. Run lando start
  2. Run lando drush status
  3. Get error

This is what lando rebuild says:
image
I can clearly see drush launcher installing.

This is what the .lando.yml file looks like:

# Name the application the same as in your .platform.app.yaml.
name: app
# Use the recipe appropriate for your application.
recipe: drupal8

# The following additional build step will install the Platform CLI
# in the application container.
services:
  appserver:
    build:
      - "curl -sS https://platform.sh/cli/installer | php"

# The following entry creates a `lando platform` command that will run
# any Platform CLI command from inside the container if desired. 
tooling:
  platform:
    service: appserver
    description: Run Platform CLI commands
    cmd:
      - /var/www/.platformsh/bin/platform
    options:
      passthrough: true
  sync:
    description: Execute script to sync files to the local machine.
    service: appserver
    cmd: /app/scripts/lando-scripts/sync.sh

config:
  # Lando defaults to Apache. Switch to nginx to match Platform.sh.
  via: nginx

  # Set the webroot to match your .platform.app.yaml.
  webroot: web

  # Lando defaults to the latest MySQL release, but Platform.sh uses MariaDB.
  # Specify the version to match what's in services.yaml.
  database: mariadb:10.1

Do you have any ideas?

@aisforaaron
Copy link

To solve this manually until Lando works try these steps.

  1. From your project root (where .lando.yml file is located) run
    $ lando ssh
  2. You should now be in the "app" dir, run
    $ composer require drush/drush
  3. Logout of ssh session
    $ exit
  4. Try drush
    $ lando drush status

@dandinu
Copy link
Author

dandinu commented Dec 30, 2017

Thanks @aisforaaron, that works, albeit the large amount of drush composer files in my git repo.

I am now able to solve this issue through a lando rebuild. It appears to be working after a couple of rebuilds. Seems random at this point, but I will try to debug a bit more.

@pirog pirog closed this as completed Jan 4, 2018
@honzapara
Copy link

This is not working for me. Once I run composer require drush/drush then it ends up with an error:

[RuntimeException]
/vendor does not exist and could not be created.

@dandinu
Copy link
Author

dandinu commented Mar 14, 2018

hi @honzapara,

As an alternative try adding drush globally by putting this in your .lando.yml:

config:
  drush: global:8.1.15

@honzapara
Copy link

This helped! Thanks a lot @dandinu.

@jasonbell
Copy link

jasonbell commented Apr 25, 2018

I still see this issue in v3.0.0-beta.39 (and bet.40 also) and it’s the only thing keeping me from getting up and running. If I manually install drush as suggested by @aisforaaron above, the repository gets littered with a pile of new vendor files. In my experience that doesn’t go well if pushed to Pantheon.

After re-installing Lando two or three times and rebuilding a few times, the note from @dandinu is the only thing gets drush working. Question is…

  1. What is happening when adding drush: global:x.x.x to the config?
  2. Shouldn’t this issue still be open? A clean installation and spin up of a Pantheon based site still gives the initial reported behavior.

@dandinu
Copy link
Author

dandinu commented Apr 26, 2018

@jasonbell the Drupal 8 recipe is specifically configured to not install drush. This is not the case for the Drupal 7 recipe, since that installs drush globally by default. I believe the logic behind it is that in D8 you would install it yourself using composer.

@jasonbell
Copy link

@dandinu Ok, thanks. That seems to make sense, however the documentation isn’t very clear on that inferred logic. The Tooling section of docs about Pantheon seems to indicate that these tools are installed by default, “ Each Lando Pantheon recipe will also ship with the Pantheon toolchain”. Maybe this is an issue of documentation?

@spencerbrooks
Copy link

Running composer require drush/drush and committing the vendor changes causes issues on Pantheon sites because it installs Drush 9 by default, which is not supported on Pantheon. Pantheon runs on Drush 8 by default, but if your repository contains a copy of Drush in the /vendor directory, it redispatches Pantheon's Drush to use that version. In my case, this broke Drush on all our Pantheon environments, including the launch check/status report.

The global approach to using Drush outlined by @dandinu is the cleanest way I've found to handle this without interfering with Drush on Pantheon. Another alternative is to commit Drush 8 to your repo, but in my opinion it's preferable to let Pantheon use whatever version of Drush they want instead of locking them to whatever's committed to your repository.

@pirog
Copy link
Sponsor Member

pirog commented May 14, 2018

@spencerbrooks (and others), after talking to @dustinleblanc i think we are going to change lando's default behavior for Drupal 8 Pantheon sites to just globally installing Drush 8.

@nerdstein
Copy link

It's a usability red flag that when you type "lando" to list, it returns a "drush" command, and drush does not work.

I also found it confusing it had to be run directly from the docroot directory when other lando commands worked outside of it.

@pirog
Copy link
Sponsor Member

pirog commented May 14, 2018

@nerdstein can you provide more detail here? i'm not exactly sure what you are trying to say.

AFAIK you don't have to run lando drush exclusively from the docroot directory. That said you DO need to run it within the context of some Lando app since drush is provided and configured on an app-to-app basis.

Re: drush not working, i think the bigger concern here is just keeping lando up to date with the myriad of ways one can install drush, how the recommended installation can be different depending on things like Pantheon, and how all of this is still very much fluid right now. We try to set a good sane default and then provide a good deal of configurability that the user can do on their end if that default doesnt match what you need.

@nerdstein
Copy link

Sure...

  1. When you run "lando" from the CLI on a site with a drupal8 recipe, it shows a command for "drush". I tried running "lando drush" and got the same Drush launcher message as posted in the issue above. This was confusing because I thought Drush would be properly configured if the command was showing up.

  2. After adding the drush version to config, I tried to run "lando drush" from the project directory (docroot was in the "www" directory). This threw another error that it could not find the docroot. I ran the same command from the "www" directory and my drush command successfully ran. I was hoping Drush would run from the project directory.

@dandinu
Copy link
Author

dandinu commented May 15, 2018

@nerdstein I had the same issue. The way I solved it was by setting the root of the drush command to point to the folder I want (in my case /app/web). Add this into your .lando.yml:

tooling:
  drush:
    service: appserver
    cmd:
      - "drush"
      - "--root=/app/web"

@pirog
Copy link
Sponsor Member

pirog commented May 15, 2018

@nerdstein these are both the expected results.

  1. The default functionality for our D8 recipe is to install the drush launcher and have the user install drush via composer. AFAIK this is the recommended way to install Drush for Drupal 8 and it also helps us not have to do version inspection to determine whether Drush 8 or Drush 9 is appropriate. That said we still let you install Drush other ways. I am pretty sure this is all documented but it's certainly possible it needs to be more clear.

  2. This is not a Lando thing this is a Drush thing. As a design principle we try not to "hijack" user commands so that they behave in the non-default way and the default way drush works is you need to run drush from a directory that contains a drupal site. That said, since Lando is pretty flexible many users have overridden their default tooling command as @dandinu has above to get the behavior you are describing.

@pirog
Copy link
Sponsor Member

pirog commented May 15, 2018

@ALL we've pushed up some docs to our recipe tutorials to make Drush usage a bit clearer for people. Here are the Drupal 8 ones: https://docs.devwithlando.io/tutorials/drupal8.html#drush

We've also talked to Pantheon and sounds like globally installing Drush 8 for Pantheon Drupal 8 sites makes the most sense for now so we've made that change and documented
https://docs.devwithlando.io/tutorials/pantheon.html#drush

It will be available in the forthcoming beta.45

@nerdstein
Copy link

Thanks for clarifying and for the improvements. I'll just highlight that I noted them as usability concerns because it took me a while to figure out what was happening. Technically, you are probably right. I appreciate the response, but I would consider what the sane defaults should be for users that want to rapidly spin up Lando and don't immediately dive into the documentation. Adding those configs that @dandinu noted should be considered as low hanging fruit, providing a functional drush command. The docs could capture where people can override or change if they need to.

@rtfm-47 rtfm-47 transferred this issue from lando/lando Nov 30, 2021
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

8 participants