drush icon indicating copy to clipboard operation
drush copied to clipboard

PHP Fatal error: Declaration of Robo\Common\ConfigAwareTrait::getConfig() must be compatible with Drush\Commands\DrushCommands::getConfig(): Drush\Config\DrushConfig in /var/www/html/vendor/consolidation/robo/src/Common/ConfigAwareTrait.php on line 34

Open joachim-n opened this issue 9 months ago • 5 comments

Describe the bug

On a new Drupal 11 project, doing drush si produces this error:

PHP Fatal error: Declaration of Robo\Common\ConfigAwareTrait::getConfig() must be compatible with Drush\Commands\DrushCommands::getConfig(): Drush\Config\DrushConfig in /var/www/html/vendor/consolidation/robo/src/Common/ConfigAwareTrait.php on line 34

To Reproduce

Installed Drupal on PHP 8.3, with the version of Drush that Composer installs by default.

Workaround

None other than hacking the file vendor/drush/drush/src/Config/ConfigAwareTrait.php by hand to remove the return type from getConfig().

System Configuration

Q A
Drush version? 13.6.0
Drupal version? 11.1.7
PHP version 8.3.19
OS? Mac, using ddev

Additional information Add any other context about the problem here.

joachim-n avatar May 12 '25 16:05 joachim-n

Seems like you have an odd version of consolidation/robo in your vendor. Maybe try to update that.

weitzman avatar Jun 24 '25 12:06 weitzman

Should Drush then declare a minimum version of consolidation/robo to prevent this?

joachim-n avatar Jun 24 '25 12:06 joachim-n

AFAIK, we do already. If we dont its a bug.

weitzman avatar Jun 24 '25 12:06 weitzman

Well this was a clean D11 install, and Composer installed that version of robo.

Also, I've just cloned 5.x of robo, and it has in Robo\Common\ConfigAwareTrait:

    public function getConfig()

joachim-n avatar Jun 24 '25 13:06 joachim-n

I'm having the same problem.

tbutterf avatar Oct 21 '25 22:10 tbutterf