1

System: Ubuntu 14.x

Drupal: 8.x

Drush: 8.x

I recently have installed Drush using composer global require drush/drush:dev-master code and it got installed successfully.

I ran command which drush and the terminal gave me the path /home/ravi/.composer/vendor/bin/drush.

The problem is, I am not able to execute any commands from project root. It gives me below error:

PHP Fatal error:  Cannot redeclare composerRequireDrupal8() (previously declared in /var/lib/composer/vendor/composer/autoload_real.php:63) in /var/www/html/study/drupal/8/vendor/composer/autoload_real.php on line 70

But when I execute below command from project root:

/home/ravi/.composer/vendor/bin/drush status

then Drush works perfectly well.

Is there any way I can use Drush from project root? Or have I made any mistakes in installation? Please help.

PS: I have tried updating composer and composer self-update but it did not help.

0

Please do not install Drush using composer global require.

Quoted from http://docs.drush.org/en/8.x/install-alternative/.

If you have Drupal 8 installed conventionally best practice would be to install Drush 8 globally by downloading the latest drush.phar, see http://docs.drush.org/en/8.x/install/.

If your Drupal 8 site is composer based then Drush 9 is probably already included. If not see http://docs.drush.org/en/master/install/.

  • So you mean, we should put drush.phar at the root of the project and use the same for routine stuff? – Ravi Maniyar May 17 '18 at 18:24
  • Yes, you can do this, but normally you place the phar file where it can be executed globally as described in the documentation. – 4k4 May 17 '18 at 18:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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