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

Prevent loading of Drush9 commands in Drush 8.x #3456

Closed
PhilippVerpoort opened this issue Mar 11, 2018 · 6 comments
Closed

Prevent loading of Drush9 commands in Drush 8.x #3456

PhilippVerpoort opened this issue Mar 11, 2018 · 6 comments

Comments

@PhilippVerpoort
Copy link

After installing Drupal 8 including Drush 9.x with composer

composer create-project drupal-composer/drupal-project:8.x-dev foldername --stability dev --no-interaction

and downgrading to Drush 8.x

composer require drush/drush:8.x

I get the following error message when trying to run drush

PHP Fatal error: Class 'Drush\Commands\DrushCommands' not found in /var/www/html/path-to-site/drush/Commands/PolicyCommands.php on line 11

Drush command terminated abnormally due to an unrecoverable error.

Error: Class 'Drush\Commands\DrushCommands' not found in /var/www/html/path-to-site/drush/Commands/PolicyCommands.php, line 11

After removing the folder 'drush' from the root directory, it works fine.

It seems as if when uninstalling Drush 9.x, Composer didn't properly remove it from the Composer project. Sorry, I'm not sure where to report this bug -- is it Composer's fault?

@weitzman
Copy link
Member

weitzman commented Mar 12, 2018

Easiest thing to do is delete PolicyCommands.php as it is made for Drush9.

I'll see what can be done about the error.

@weitzman
Copy link
Member

This was probably introduced when drupal-composer/drupal-project#351 went in.

@weitzman
Copy link
Member

@greg-1-anderson said he may look into preventing the loading of these commands in 8.x

@weitzman weitzman changed the title Cannot downgrade to Drush 8.x after installing Drupal 8 with Composer Prevent loading of Drush9 commands in Drush 8.x Mar 13, 2018
@greg-1-anderson
Copy link
Member

Drush 8.1.17 has some basic interoperability with Drush 9 command files, so the policy file from drupal-composer/drupal-project no longer crashes Drush 8.

@weitzman weitzman closed this as completed Apr 3, 2019
@leymannx
Copy link
Contributor

Is the following related? I can't use my global Drush 8.2.3 anymore inside a non-Composer D7 due to the following error. I think this happened after I cloned Drush master into the folder above the non-Composer D7 project. Renaming the drush directory to something different solved it.

$ drush8 -y sql-drop
Drush command terminated abnormally due to an unrecoverable error.   [error]
Error: Class 'Drush\Commands\DrushCommands' not found in
/Users/leymannx/Sites/drush/src/Commands/pm/SecurityUpdateCommands.php,
line 15

@greg-1-anderson
Copy link
Member

Drush will look for preferences in a directory named 'drush' in the folder above the document root. Perhaps this code could detect and exclude directories that were entire Drush installs.

You should try with 8.3.0 and see if that works better, too.

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