webflo / drupal-finder

GNU General Public License v2.0
125 stars 26 forks source link

Problem detecting DrupalRoot on Drupal 8.7 #46

Open Etroid opened 5 years ago

Etroid commented 5 years ago

DrupalFinder is unable to detect drupalRoot is /web when using drupal core 8.7 - using wikimedia/composer-merge-plugin. Instead, it thinks the drupalRoot is /.

This issue occurs when running any drush or drupal command.

{
  "require": {
    "drupal/console": "~1.0",
    "drupal/core": "^8.7",
    "drush/drush": "^9.2"
  },
  "extra": {
    "installer-paths": {
      "web/core": [
        "type:drupal-core"
      ],
      "web/modules/contrib/{$name}": [
        "type:drupal-module"
      ],
      "web/profiles/contrib/{$name}": [
        "type:drupal-profile"
      ],
      "web/themes/contrib/{$name}": [
        "type:drupal-theme"
      ],
      "drush/contrib/{$name}": [
        "type:drupal-drush"
      ]
    }
  }
}

From what I gather this is because of a recent change to support Drupal core 8.8 (i.e. https://www.drupal.org/project/drupal/issues/2912387#comment-13188592)

webflo commented 5 years ago

Did you specify a name property in your composer.json?

Etroid commented 5 years ago

yes, the snippet is just part of the entire composer.json file All was working last week, a few days before the latest release of drupal-finder

simesy commented 5 years ago

Check if your main project composer.json is set to:

{
    "name": "drupal/drupal",
    ...

I had an old project I inherited that must have been initially modelled on the drupal composer.json. The update on Aug 2 added logic that looks for drupal/drupal and sets the Drupal Root incorrectly.

I'm guessing this was webflo's hunch...

simesy commented 5 years ago

Something to note, this problem didn't occur for me when the entry point was Drush launcher. It only occured when i was explicitly doing like ../vendor/bin/drush status from the Drupal root.

Etroid commented 5 years ago

^^ @simesy correct, I was not using drush launcher when I encountered the problem. It was working before the latest release however.

simesy commented 5 years ago

@Etroid you haven't verified what that value of "name" is in your composer.json.

Etroid commented 5 years ago

@simesy, name is "name": "tableau/www" so should not be related.

Techwolf12 commented 5 years ago

Same issue here, using the lightning distribution. "name": "drupal/drupal",

Except the composer.json isn't in the docroot, but one directory outside of it for security reasons. I think that is related to the issue. I downgraded to 1.1.0 for now to get it working. So a quick fix: composer require webflo/drupal-finder:1.1.0

simesy commented 5 years ago

@Techwolf12 yeah that is pretty standard, drupal-finder is designed start in the docroot and look up a directory for the composer file.

"name": "drupal/drupal", is arguably incorrect because it collides with the well known composer package drupal/drupal, see attached image as evidence that Composer assumes this would never happen. It works because you're likely requiring bringing in the composer-friendly variation drupal/core.

I would change it. I've never seen negative consequences of changing it. I usually change it to ORGANISATION/PROJECT.

Screen Shot 2019-09-24 at 9 49 04 AM
pjcdawkins commented 5 years ago

Or remove it, there's no need for a "name" in a not-published Composer project.