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

Support non-composer D7 installs #35

Open
DuaelFr opened this issue Feb 1, 2018 · 12 comments
Open

Support non-composer D7 installs #35

DuaelFr opened this issue Feb 1, 2018 · 12 comments

Comments

@DuaelFr
Copy link

DuaelFr commented Feb 1, 2018

While in a D7 root directory, I can't use drush launcher because it does not recognize a Drupal installation.

project/www $ drush --version
Drush Launcher Version: 0.5.1
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.
project/www $ drush --root=. --version
Drush Launcher Version: 0.5.1
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.

My D7 is not installed via composer (5 years old project).
It is in a www folder, at the same level of the composer.json that's used to require drush 8.

project $ tree -L 2 .
.
├── composer.json
├── composer.lock
├── drush
│   └── contrib
├── README.md
├── scripts
│   └── [...]
├── vendor
│   ├── autoload.php
│   ├── bin
│   ├── [...]
│   ├── drush
│   └── [...]
└── www
    └── [Drupal root]
@webflo
Copy link
Owner

webflo commented Feb 1, 2018

@DuaelFr Could you post your composer.json as well?

@DuaelFr
Copy link
Author

DuaelFr commented Feb 5, 2018

Sure!
Prepare to be stunned ;)

$ cat composer.json 
{
    "require": {
        "drush/drush": "~8.0"
    }
}

(I told you it is not a project built with composer ^^)

@webflo
Copy link
Owner

webflo commented Feb 5, 2018

drupal-finder relies on the configuration for composer installers. You could try to make it work. If you configure these path accordingly to your structure. Even if you don't install drupal core via composer.

@webflo
Copy link
Owner

webflo commented Feb 5, 2018

@DuaelFr
Copy link
Author

DuaelFr commented Feb 5, 2018

It works, thanks!
It would be great if it was documented, maybe in your readme? :)

@markusd1984
Copy link

markusd1984 commented Mar 7, 2018

How did you make it work?
Sorry for n00b question, which path did you put where @DuaelFr ?

I got the same issue on my D7 non-composer install :D

@DuaelFr
Copy link
Author

DuaelFr commented Mar 7, 2018

Here is my composer.json file. My drupal root is located in the www directory.

{
    "require": {
        "drush/drush": "~8.0"
    },
    "extra": {
        "installer-paths": {
            "www": ["type:drupal-core"],
            "www/sites/all/libraries/{$name}": ["type:drupal-library"],
            "www/sites/all/modules/contrib/{$name}": ["type:drupal-module"],
            "www/profiles/contrib/{$name}": ["type:drupal-profile"],
            "www/sites/all/themes/contrib/{$name}": ["type:drupal-theme"],
            "drush/contrib/{$name}": ["type:drupal-drush"]
        }
    }
}

I suppose the only important line is the type:drupal-core one but I don't really know.

@capynet
Copy link

capynet commented Jun 27, 2018

Ok there you are. This is my working composer.json for D7 installations.

{
  "require": {
    "drush/drush": "~8.0",
    "webflo/drupal-finder": "^1.0.0"
  },
  "extra": {
    "installer-paths": {
      ".": [
        "type:drupal-core"
      ]
    }
  }
}

@wdseelig
Copy link

Sorry to bother, but could you please point me to where I could learn how to use this composer.json to enable drush for my non-composer created vagrant D7 site? Where do I put his file, and what do I then to to run it and enable drush?

@leymannx
Copy link
Contributor

@wdseelig – Seems off-topic to me, as this is the drupal-finder repo, not drush-launcher. But for what it's worth: It's absolutely not recommended (not supported) to use a local Drush in a non-Composer managed site. See drush-ops/drush-launcher#33 (read until the end).

You are putting your site at risk doing it that way. Since running drush up for example can potentially delete your whole web directory (tracked or untracked files all gone).

Instead consider to Composerize your project using https://github.com/grasmash/composerize-drupal first.

@capynet
Copy link

capynet commented May 14, 2019

@wdseelig what's saying @leymannx have a lot of sense. I did this for a custom need so please keep this in mind.

In my example I just added a composer.json with the mentioned code inside at the D7 root dir and runned composer install.

@vickyhawley
Copy link

Hiya,
I also had this issue, but I am being told to not use drush launcher by a colleague, so how do I get rid of drush launcher? sorry if this is a stupid question!

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

No branches or pull requests

7 participants