5

Edit: re-wrote intro paragraph to highlight the installation of composer - I suspect composer may have broken drush.

I want to test out elastic search with D7. I used drush to install a fresh D7 install, then views, elasticsearch_connector, libraries. At that point Watchdog indicated that I was missing the elasticsearch-php library.

I tried to follow Elasticsearch's instructions on getting this library and installed composer:

/sites/mysite $ curl -sS https://getcomposer.org/installer | php
#!/usr/bin/env php
All settings correct for using Composer
Downloading...

Composer successfully installed to: /sites/aarp/composer.phar
Use it: php composer.phar
/sites/mysite $ sudo mv composer.phar /usr/local/

I added an alias for composer to my ~/.profile. I have not been able to use any drush commands since (see below). I have since discovered that composer can be used to install drush so now I suspect this is the root of my trouble.

/sites/mysite $ drush en composer_manager -y
composer_manager was not found.                                                                                                                                        [warning]
The following projects provide some or all of the extensions not found:                                                                                                [ok]
composer_manager
Would you like to download them? (y/n): y
cProject composer_manager (7.x-1.7) downloaded to sites/all/modules/composer_manager.                                                                                   [success]
dThe following extensions will be enabled: composer_manager
Do you really want to continue? (y/n): y
composer_manager was enabled successfully.                                                                                                                             [ok]
One or more extensions have dependencies managed by Composer.
Update packages managed by Composer? (y/n): y
Download and install the Drush Composer extension? (y/n): y
Directory /Users/mmutrux/.drush exists, but is not writable. Please check directory permissions.                                                                       [error]
Project composer (8.x-1.x-dev) could not be downloaded to /Users/mmutrux/.drush/composer.                                                                              [error]
The drush command 'composer' could not be found.                                                                                                                       [error]
/sites/mysite $ chgrp _www /Users/m
macadmin/ mmutrux/  
/sites/mysite $ chgrp _www /Users/mmutrux/.drush/
chgrp: you are not a member of group _www
/sites/mysite $ chgrp _www /Users/mmutrux/.drush/
/sites/mysite $ chmod 777 /Users/mmutrux/.drush/
chmod: Unable to change file mode on /Users/mmutrux/.drush/: Operation not permitted
/sites/mysite $ sudo chmod 777 /Users/mmutrux/.drush/
Password:
/sites/mysite $ drush en composer_manager -y
The drush command 'en composer_manager' could not be found.  Run `drush cache-clear drush` to clear the commandfile cache if you have installed new extensions.        [error]
/sites/mysite $ drush cache-clear drush
The drush command 'cache-clear drush' could not be found.  Run `drush cache-clear drush` to clear the commandfile cache if you have installed new extensions.          [error]

Where'd my drush go??

Edit: added in response to comments

/sites/mysite $ which drush
/opt/local/bin/drush
/sites/mysite $ drush --version
The drush command 'version' could not be found.  Run `drush cache-clear drush` to clear the commandfile cache if you have installed new extensions.                    [error]
/sites/mysite $ sudo drush --version
The drush command 'version' could not be found.  Run `drush cache-clear drush` to clear the commandfile cache if you have installed new extensions.                    [error]
/sites/mysite $ drush --version -v
Initialized Drupal 7.35-dev root directory at /sites/aarp                                                                                                                 [notice]
Initialized Drupal site default at sites/default                                                                                                                          [notice]
The drush command 'version' could not be found.  Run `drush cache-clear drush` to clear the commandfile cache if you have installed new extensions.                    [error]
8
  • Sounds like permission issues but it would probably be easier to just start over...just for kicks what does "drush --version" and/or "which drush" say? Commented Jan 9, 2015 at 2:30
  • @burnsjeremy Good idea. Looks like drush can't even find it's own version.
    – doub1ejack
    Commented Jan 9, 2015 at 16:35
  • What did "which drush" output? And did the "drush --version" just error out? Try adding a -v (verbose tag) to get some more helpful output. Commented Jan 9, 2015 at 16:38
  • @burnsjeremy See edit at the end of my post.
    – doub1ejack
    Commented Jan 9, 2015 at 16:42
  • Is the /opt a personal preference? Normally "which drush" gives /usr/local/bin/drush Commented Jan 9, 2015 at 16:51

5 Answers 5

1

I'm not sure if this will help anyone but if you do ever run into this issue:

This seemed to be a permissions issue from the beginning, so in chat we:

  • Removed the old drush and composer instances.
  • Installed Composer
  • Downloaded Drush from Github
  • Installed dependencies via Composer

Once we had a fresh copy of drush it seems that drush now worked just fine. We had some small issues that came from the machine that was being used.

9

Being inspired by comment by Free Radical, it works for me even without removing .composer directory:

  1. drush cc all outside the Drupal root directory
  2. drush cc all inside the Drupal root directory
1

I was bitten by the same problem after trying to install Composer Manager for D7 using this command:

drush en composer_manager -y

The installation crashed, and after that, drush responded “The drush command X could not be found” for every X, including cc and version.

This is what I did to get it working again:

  1. Removed a directory named .composer that had been created in my home directory.
  2. Did drush cc all outside of the Drupal root (this now works).
  3. Did navigate to the Drupal root, and did drush cc all again (this now works).

I haven't done any testing to see if all these steps are necessary - just posting it in case it helps someone who wants to recover from this without reinstalling drush.

1

For me, using Drupal in a Docker image with Bowline I hit the same problem, but the drush cc all method didn't work, and I didn't want to trash Bowline's composer installations.

But taking the hints from above, I found that manually deleting the ./.drush/cache directory in my project root (same level as Bowline's bin) fixed drush. I hope that helps someone with the same circumstances.

1
  • This also worked for Travis CI and Drupal TI scripts.
    – Brady
    Commented Feb 25, 2016 at 17:02
0

A one-liner approach...

pushd $HOME && drush cc drush && popd

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.