drush-launcher icon indicating copy to clipboard operation
drush-launcher copied to clipboard

The Drush launcher could not find a Drupal site

Open petiar opened this issue 7 years ago • 19 comments
trafficstars

drush --debug output

ROOT: /var/www/html/debates/web/my-website
The Drush launcher could not find a Drupal site to operate on. Please do *one* of the following:
  - Navigate to any where within your Drupal project and try again.
  - Add --root=/path/to/drupal so Drush knows where your site is located.

The path /var/www/html/debates/web/my-website contains Drupal 7 installation. What shall I do???

petiar avatar Feb 20 '18 10:02 petiar

I have this problem too. I'm using this in a drupalvm installation.

As a workaround, I'm now using drush global instead of drush launcher. But would be good to know why we're having this problem with drush launcher.

victoriachan avatar Feb 23 '18 10:02 victoriachan

This might provide some insight. It seems the problem is with using drush launcher on a non-Composer D7 project: https://github.com/drush-ops/drush-launcher/issues/33 and https://github.com/webflo/drupal-finder/issues/35 (this one seems to have the solution)

victoriachan avatar Feb 23 '18 11:02 victoriachan

#49 seems to have a fix too.

heddn avatar Mar 05 '18 20:03 heddn

I followed fix from above only to be met with a new error:

Fatal error: Uncaught Error: Call to undefined function drush_main() in phar:///usr/local/bin/drush/bin/drush.php:153
Stack trace:
#0 /usr/local/bin/drush(10): require()
#1 {main}
  thrown in phar:///usr/local/bin/drush/bin/drush.php on line 153

So it is clearly seeing that it's Drush 8, but that function is not available.

shelane avatar Mar 20 '18 22:03 shelane

Go to the Drupal's root directory, create a composer.json with below snippets and then execute composer install

composer.json

{
    "require": {
        "drush/drush": "8.*"
    },
    "extra": {
        "installer-paths": {
            "core": ["type:drupal-core"]
        }
    }
}

dbjpanda avatar Apr 03 '18 22:04 dbjpanda

@shelane Did you ever find a fix for that error?

crittermike avatar Apr 17 '19 16:04 crittermike

I am using Docksal now and I don't have Drush Launcher installed locally. Everything I call is now in my container and I haven't had an issue.

shelane avatar Apr 17 '19 19:04 shelane

from the root directory run

composer require drush/drush

isalmanhaider avatar Nov 14 '19 07:11 isalmanhaider

This error also occurs when there is a syntax error in your composer.json.

I had manually edited composer.json to remove the last required package but neglected to delete the trailing comma of the item that was now the last item in the list. Once I removed the comma Drush started working again.

RogerBailey avatar Feb 03 '20 01:02 RogerBailey

I had the same problem using drush v.8.3.2, using an older version worked for me (I used v.8.0.5)

wget https://github.com/drush-ops/drush/releases/download/8.0.5/drush.phar

alevani avatar Feb 12 '20 11:02 alevani

Looks like the newer versions of DrupalVM specify the following in composer.json:

{
  "require": {
    "geerlingguy/drupal-vm": "4.*",
    "drush/drush": "^10.2"
  }
}

As we're still using Drupal 7 for the corporate site at this stage, we require an earlier version of Drush. This can be provided by changing the version requirements.

E.g.

  "require": {
    "geerlingguy/drupal-vm": "4.*",
    "drush/drush": "^8.0"
  }
}

Once updated, composer update and you should be good to go.

lukewhitmore avatar Apr 06 '20 13:04 lukewhitmore

For me it was an empty composer.json in the webroot that has been created when I accidentally required a package in there but quit before it finished. Removing the empty composer.json fixed it.

$ drush -y updb

In Process.php line 256:

  The command "/usr/local/bin/drush updatedb:status --no-entity-updates --uri=default --root=/Users/leymannx/Sites/foobar/web" failed.

  Exit Code: 1(General error)

  Working directory:

  Output:
  ================
  The Drush launcher could not find a local Drush in your Drupal site.
  Please add Drush with Composer to your project.
  Run 'cd "/Users/leymannx/Sites/foobar/web" && composer require drush/drush'

normanlolx avatar Jul 23 '20 15:07 normanlolx

I'm having the same problem and none of these fixes are helping.

../../../vendor/drush/drush/drush status works just fine.

drush status cannot find a drupal directory.

I have this working on my old computer, having a hard time on a new machine. ..."needs a higher bootstrap level to run - you will need to invoke drush from a more functional Drupal environment to run this command."

SeeyaSia avatar Apr 26 '21 19:04 SeeyaSia

I was having the same problem after I set up a new drupal site on my local dev env. However drush launcher seemed to learn the location of the new drupal install after I ran drush self-update

SteveLefevre-Moodys avatar Apr 12 '22 17:04 SteveLefevre-Moodys

../../../vendor/drush/drush/drush status works just fine.

You can use vendor/bin/drush instead of vendor/drush/drush/drush

And as the previous comment said, I had the issue after updating my site to Drush 11, but once I updated the Drush Launcher using self-update to 0.10.1 the error went away.

mbomb007 avatar Jul 05 '22 14:07 mbomb007

I think I have the same issue and need drush to run utf8mb4 conversion.

I have a server that need to be able to use drush with old D7 and maybe later with newer Drupal versions in parallel. Previously I used https://github.com/webflo/drush-shim/releases/download/0.2.4/drush.phar and when I checked the https://github.com/webflo/drush-shim site for latest version I was redirect to drush-launcher. So I thought I need to use the one here as the old project is not reachable anymore and redirects.

How can we solve this issue for D7 now?

alexhass avatar Sep 24 '22 20:09 alexhass

hm... I downloaded https://github.com/drush-ops/drush/releases/download/8.4.11/drush.phar and placed it in /usr/local/bin. Based on https://www.drush.org/latest/install/ latest Drush supported is 8.x.

Why do we need drush-launcher project? I'm confused...

alexhass avatar Sep 24 '22 20:09 alexhass

There's some earlier comments that might be related to your issue.

Read the README.md to understand the purpose of this project.

mbomb007 avatar Sep 26 '22 13:09 mbomb007

I was getting the same error on D7 and https://github.com/drush-ops/drush-launcher/issues/45#issuecomment-378414568 worked, thanks a lot.

kartagis avatar Aug 18 '23 13:08 kartagis