Problem/Motivation

After running composer update including an update of Search API to 8.x-1.36, Drush stops working and gives the error message:

PHP Fatal error: Trait "Drush\Commands\AutowireTrait" not found in /var/www/web/modules/contrib/search_api/src/Drush/Commands/SearchApiDrushCommands.php on line 23
[warning] Drush command terminated abnormally.

This is due to running a Drush version < 12.5 on my instance (having Drush 12.4.3). Same issue was already reported to the Drush development team for the Devel-module, see https://github.com/drush-ops/drush/issues/5941

Proposed resolution

The resolution is described in the same issue in this comments: https://github.com/drush-ops/drush/issues/5941#issuecomment-2025263217 https://github.com/drush-ops/drush/issues/5941#issuecomment-2025352930 - the Devel resolution is to set "drush/drush": "<12.5.1" as conflict in composer.json. Could this also be a solution for search_api?

As a workaround run composer require 'drush/drush:^12.5' for your instance. Then the error disappears.

Issue fork search_api-3489598

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

kil created an issue. See original summary.

kil’s picture

Issue summary: View changes
kil’s picture

Issue summary: View changes

drunken monkey made their first commit to this issue’s fork.

drunken monkey’s picture

Status: Active » Needs review

Thanks for the suggestion, seems sensible!
We don’t really need that trait so would also have been quite easy to make do without it for now, but I guess requiring a relatively new Drush version doesn’t do much harm, either. So, I went with that and created an MR. Please test/review!

drunken monkey’s picture

I changed my mind, let’s keep compatibility and get rid of the AutowireTrait.
Changed the MR, please test!

  • drunken monkey committed e10225fa on 8.x-1.x
    Issue #3489598 by drunken monkey: Fixed incompatibility with older Drush...
drunken monkey’s picture

Status: Needs review » Fixed

Merged.
Thanks again!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.