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

How to use drush? #52

Closed
michaellenahan opened this issue Sep 2, 2015 · 6 comments
Closed

How to use drush? #52

michaellenahan opened this issue Sep 2, 2015 · 6 comments

Comments

@michaellenahan
Copy link
Contributor

When we are in the web directory, we can run drush like this:

cd web
../vendor/drush/drush/drush cr

Dumb question, but is there a better way to do it?

We can't currently add a symlink to the web directory, because the drush directory is already there.

cd web
ln -s ../vendor/drush/drush
ln: failed to create symbolic link ‘./drush’: File exists
@rodrigoaguilera
Copy link
Contributor

I personally use it on bash scripts
You can set a bash variable that holds the bin full path or instead of the variable alias drush and unalias it at the end.

@derhasi
Copy link
Member

derhasi commented Sep 3, 2015

Generally drush has a "redispatch" feature that can be enabled with setting $options['drush-script'] to the path of your project specific drush. See #16 (comment) for details. From what I understand you will need the latest drush version to be installed globally to make this work.
Maybe @greg-1-anderson can clarify it a little bit more.

For general use cases I created an experimental 💥 helper command to be installed globally: https://github.com/derhasi/buddy. With that small tool you could call drush via b drush ... from any place in your project, by simply defininy a .buddy.yml.

@greg-1-anderson
Copy link
Collaborator

We are going to solve this with drush-ops/drush#1343; in particular, see my comment on 18 May (I really need to get back to this issue....)

The general idea is that we will put this drush finder feature in Drush 7.x and Drush 8.x. When you run drush, it will launch the drush finder in your $PATH (which is to say, it will run your global Drush). This script in turn will notice that you have a site-local Drush associated with the site you have selected. It will launch this Drush directly, rather than your global Drush.

@webflo
Copy link
Member

webflo commented Sep 29, 2015

https://github.com/webflo/drushenv is one solution to the problem. Just run echo "site" > .drush-version in your project root and commit the .drush-version file. Drushenv will automatically dispatch all drush commands to the project specific drush installation.

@greg-1-anderson
Copy link
Collaborator

drushenv is a good solution. We are about to merge drush-ops/drush#1343 (later today, probably), so shortly you will be able to try that out. Just install a version of Drush that contains the 'drush finder' script as your global Drush, and it will find and launch the correct site-local Drush for you.

So:

cd web
drush cr

Regarding the fact that web/drush already exists, you may create web/drush.wrapper, and the Drush 'finder' script will launch that instead of web/vendor/bin/drush if it is found. The purpose of doing this is to add options such as --local, paths to Drush configuration files, and so on. See the comments in the above-referenced Drush issue.

bradjones1 added a commit to bradjones1/drupal-project that referenced this issue Oct 5, 2015
Now that drush-ops/drush#1595 has landed, and per the comments in drupal-composer#52, the new "finder" stage for Drush is helpful/necessary to use the copy in the vendor directory. In my case, this works without any other changes or magic; I have a global /etc/drush/drushrc.php file that specifies the path to Drush, but this works inside the web/ directory, as well.

Also removed an unnecessary blank line.
@webflo
Copy link
Member

webflo commented Oct 8, 2015

The drush launcher feature landed in drush core and it just works. Thanks @greg-1-anderson!

@webflo webflo closed this as completed Oct 8, 2015
g3r4 pushed a commit to Bixal/drupal-project that referenced this issue May 6, 2019
Feature/WIOA-426 init script

Approved-by: Gerardo Maldonado <[email protected]>
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

5 participants