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

Any alternatives of drush launcher for Drush 12 (drush command does not work with drush 12,instead we have to run drush command with vendor/bin/drush) #5825

Closed
sananeyazi-voya opened this issue Dec 1, 2023 · 5 comments

Comments

@sananeyazi-voya
Copy link

sananeyazi-voya commented Dec 1, 2023

Describe the bug

We have Acquia/BLT based Drupal 10 (10.0) site and using DRUSH as a dependency in our site. We have to update the latest blt library (acquia/blt 13.7.4) which requires drush version 12. But when we run drush commands with drush12, we are getting below message

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

So we have to run drush with vendor/bin/drush instead of only drush

Found few issues which states drush-launcher does not support by drush12
Islandora-Devops/isle-buildkit#286
Islandora-Devops/isle-buildkit#283
drush-ops/drush-launcher#106

Also tried suggesstions given in above links, but nothing works in our case.

Can anyone please suggest any alternatives of drush-launcher or solution to fix this problem?
Your help would be much appreciated

To Reproduce
Install drupal 10.0
Install drush 12( with drush launcher)
php 8.1
Run any command suppose 'drush cr'

Expected behavior
Drush command should run without adding vendor/bin

System Configuration

| --------------- | ---
| Drush version? | 12.4.3
| Drupal version? | 10.0.11
| PHP version | 8.1
| OS? | Linux

@sananeyazi-voya sananeyazi-voya changed the title Drush launcher alternatives for Drush 12 (drush command does not work with drush 12,instead we have to run drush command with vendor/bin/drush) Any alternatives of drush launcher for Drush 12 (drush command does not work with drush 12,instead we have to run drush command with vendor/bin/drush) Dec 1, 2023
@gitressa
Copy link
Contributor

gitressa commented Dec 1, 2023

I just tested this, and following this guide seems to work:

  1. Execution. Change your working directory to your project root, and call Drush via vendor/bin/drush. To make this easier, append ./vendor/bin to the end of your $PATH; this allows you to call Drush via drush once your working directory is set. If you only have only one Drupal codebase on your system, you may put /path/to/vendor/bin/drush in your $PATH; if you do this, then it is not necessary to set your working directory before calling Drush.

From https://www.drush.org/latest/install/.

This works well in my ~/.profile file, allowing me to use drush st:

# add Drush, see https://www.drush.org/latest/install/
PATH="./vendor/bin:$PATH"

I also tried with /path/to/vendor/bin/drush but that does not work ...

@gitressa
Copy link
Contributor

gitressa commented Dec 1, 2023

Like I wrote, I tried the "run Drush from any folder" option, which never worked for me before. I realized it is due to a wrong path in the documentation, so I have created the merge request #5826, which fixes this.

@YahyaAhmad
Copy link

YahyaAhmad commented Jan 4, 2024

@gitressa
Copy link
Contributor

gitressa commented Jan 4, 2024

Thanks! Feel free to share it in #5828, where this is dicussed.

@derjochenmeyer
Copy link

derjochenmeyer commented Feb 26, 2024

PATH="./vendor/bin:$PATH"

This works but only in the root directory of the Drupal instance.

The following works in all sub directories.

function drush() {
    local dir=$(pwd)
    while [ "$dir" != "/" ]; do
        if [ -x "$dir/vendor/bin/drush" ]; then
            "$dir/vendor/bin/drush" "$@"
            return
        fi
        dir=$(dirname "$dir")
    done
    echo "Drush executable not found."
}

Test it with drush status

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

4 participants