backdrop-contrib / backdrop-drush-extension

A set of commands and boot class for Drush and Backdrop CMS.
GNU General Public License v2.0
13 stars 18 forks source link

'version' bootstrap issue #231

Open ghost opened 3 years ago

ghost commented 3 years ago

The version command doesn't work properly:

Command backdrop-drush-version needs a higher bootstrap level to run - you will need to invoke drush from a more functional Drupal environment to run this command.   [error]
The drush command 'version' could not be executed.                                                                                                                    [error]

This also cases an issue in Lando: https://github.com/lando/lando/issues/2695

ghost commented 3 years ago

Simple fix: https://github.com/backdrop-contrib/backdrop-drush-extension/pull/232

klonos commented 3 years ago

Trying to review pending PRs, I have to say that I've never had issues with (lando) drush version. How do I reproduce this @BWPanda?

ghost commented 3 years ago

@klonos Steps to reproduce (replace test below with something else if you already have a Lando instance with that name):

  1. mkdir test && cd test
  2. lando init
    From where should we get your app's codebase? current working directory
    What recipe do you want to use? backdrop
    Where is your webroot relative to the init destination? .
    What do you want to call this app? test
  3. lando start - note that Lando starts without any errors
  4. lando drush version - note the error:
    Command backdrop-drush-version needs a higher bootstrap level to run - you will need to invoke drush from a more functional Drupal environment to run this command. [error]
    The drush command 'version' could not be executed. [error]
  5. lando rebuild - note the errors this time:
    Command backdrop-drush-version needs a higher bootstrap level to run - you will need to invoke drush from a more functional Drupal environment to run this command. [error]
    The drush command 'version' could not be executed. [error]
    ERROR ==> The drush command 'version' could not be executed. [error]
    ...
    ■ One of your build steps failed
      This **MAY** prevent your app from working.
      Check for errors above, fix them in your Landofile, and try again by running:
      lando rebuild

Subsequent lando rebuild causes the same error to be displayed each time, and apparently that also causes it to try and download Lando again each rebuild: https://github.com/lando/lando/issues/2695

Hope tht helps!

klonos commented 3 years ago

Thanks @BWPanda ...I was able to reproduce.

I almost never rebuild my local lando; I always build once, then destroy when done. Perhaps that's why I never noticed this issue before.

Anyway, I know that you can do something like so:

name: test
recipe: backdrop
config:
  webroot: .
  backdrush: 1.x-1.x

And get to test the latest changes committed to the 1.x branch of this project, but how do I actually get to test PRs?

ghost commented 3 years ago

To test this PR, add the following to your .lando.yml file:

services:
  appserver:
    run_as_root:
      - cd /var/www/.drush && wget https://patch-diff.githubusercontent.com/raw/backdrop-contrib/backdrop-drush-extension/pull/232.patch
      - cd /var/www/.drush && patch -p1 < 232.patch

After doing so and running lando rebuild (may need to run that command twice), I can successfully run lando drush version without errors, and then rebuilding happens without errors too.

ghost commented 3 years ago

@serundeputy @quicksketch Any chance this can get approved and merged, or does this quality as something the @backdrop-contrib/bug-squad can do...?

jenlampton commented 3 years ago

Bug-squad can merge it if it has been RTBC for two weeks. We need someone else to review + confirm it works if not @serundeputy or @quicksketch

ghost commented 3 years ago

@jenlampton Ah ok, thanks.

@klonos How'd you go with this? Were you able to confirm the PR works to fix the bug?

klonos commented 3 years ago

Sorry for the late response here, and thanks for pinging me on Zulip @BWPanda 🙏 ...I've tested the PR on my local, and I am no longer able to reproduce the problem ...running lando drush version does not throw any errors before or after lando rebuild 👍 ...RTBC!

serundeputy commented 3 years ago

@BWPanda @klonos this is not working for me

I've tried

Each lando rebuild -y is still throwing errors for me.

(base) gff ~/code/drush-ops/232-drush-version 
() └─ ∴ lando drush version
Command backdrop-drush-version needs a higher bootstrap level to run - you will need to invoke drush from a more functional Drupal environment to run this command.                                                                                  [error]
The drush command 'version' could not be executed.                                                                                                                                                                                                   [error]

I've run out of time to continue testing and troubleshooting. That said you can merge this if you want, it doesn't make anything any worse or better as far as i can tell.

ghost commented 3 years ago

@serundeputy Weird. Definitely works for me. Here's the Lando config I'm using:

name: drush-version-test
recipe: backdrop
config:
  webroot: .
services:
  appserver:
    run_as_root:
      # - cd /var/www/.drush && wget https://patch-diff.githubusercontent.com/raw/backdrop-contrib/backdrop-drush-extension/pull/232.patch
      # - cd /var/www/.drush && patch -p1 < 232.patch

I start Lando with that config then run lando drush version and it displays the error. I rebuild and it has an error during rebuild too. Running the same command after rebuild still errors. Then I uncomment the two commented lines in the Lando config and rebuild again. It still shows the rebuild error, but once it's built I can run lando drush version without errors. If I rebuild again now, that works too.

So the rebuild errors happen whenever there was an error before you rebuilt. I.e. when it tries to get the Drush version during a rebuild, it happens before the patch command, so it's still using the unpatched version initially. Once you're able to successfully run lando drush version, then rebuilding will work without errors.

BTW, if it helps, I'm using Lando v3.0.23, Drush (proper) 8.3.5 and Backdrop Drush 1.x-1.x. Will try to get others to see if they can confirm patch works or not.

ghost commented 3 years ago

I just updated the PR to change DRUSH_BOOTSTRAP_DRUSH to DRUSH_BOOTSTRAP_NONE, since the latter is an official bootstrap phase, and more widely used in other Backdrop Drush commands.

Even without reproducing the problem and testing the PR, I think it's clear that this change is necessary and worthwhile... As per the documentation for writing commands for the main Drush project, the default bootstrap phase is DRUSH_BOOTSTRAP_DRUPAL_LOGIN. Since Backdrop's version command doesn't currently specify a bootstrap phase, it inherits the Backdrop equivalent bootstrap phase. As per the bootstrap documentation, the default DRUSH_BOOTSTRAP_DRUPAL_LOGIN phase "is used after the site has been fully bootstrapped." This is why trying to get the version of Drush in certain contexts (e.g. building your Lando config) doesn't work, because the website hasn't been fully bootstrapped yet. In fact, you should be able to get the version of Drush without any Backdrop (or Drupal) site being bootstrapped. Like the documentation says: "some commands are useful even when you don't have a working Drupal site. For example, you can use Drush to download Drupal with drush dl drupal. This obviously does not require any bootstrapping to work." Drush's version command uses the DRUSH_BOOTSTRAP_NONE bootstrap phase for exactly this reason, so should we.

That said you can merge this if you want

So with @serundeputy's blessing, I'll ask @klonos to merge the PR please, then we can continue testing to make sure all works as expected when rebuilding Lando sites.

klonos commented 3 years ago

Thanks for doing that extra research and providing all that info @BWPanda 👍 ...it all makes sense, and with @serundeputy's blessing, I've merged this into 1.x-1.x

klonos commented 3 years ago

Good news: I've tested things again on some of my local sandboxes (all of which use backdrush: 1.x-1.x), and I confirm that there are no errors when running lando drush version after rebuild 👍

Bad news: I've also tested with the steps provided in https://github.com/backdrop-contrib/backdrop-drush-extension/issues/231#issuecomment-757075607 (without any codebase present - backdrop or otherwise), and this time I got the usual errors 👎

@BWPanda wanna have another look?

ghost commented 3 years ago

I've also tested with the steps provided in #231 (comment) (without any codebase present - backdrop or otherwise), and this time I got the usual errors 👎🏻

I imagine that's because that setup doesn't specify backdrush: 1.x-1.x and so uses the default version of Backdrop's Drush, which seems to be 1.4.0. To fix that, we'd need @serundeputy to make a new release for Backdrop's Drush, then ask Lando to update their default version to match.

I'm not having any issues with a new Lando build, but I am sill having issues with my existing Sandbox. I suspect it's some sort of caching thing, which a lando destroy && lando start will fix, but I'm not willing to do that yet (WIP). So I'm happy to close this as fixed now.

sdubois commented 8 months ago

I am getting this error message on lando v3.20.8 using the backdrop recipe every time I run lando rebuild.

Command backdrop-drush-version needs a higher bootstrap level to run - you will need to invoke drush from a more functional Drupal environment to run this command.                                                                                  [error]
The drush command 'version' could not be executed.                                                                                                                                                                                                   [error]
ERROR ==>