Skip to main content

Problem with Drush and PHP 8.1

Submitted by admin on
drush

Drush (Drupal Shell) is one of the best tools for developers under Drupal (CMS), this tool allows the execution of various instructions at the database level, configurations, and generating base code for modules among other benefits.
When Drupal 9.5 arrived several users experienced problems with drush and PHP 8.1, thinking that maybe it could be a contributed module that is giving problems or Drupal itself, going through many tests to determine the cause of the problem.

  • Segmentation fault
  • [Warning] Drush command terminated abnormally

These two error messages appear when running drush updb -y, drush cr respectively
You can examine these commands in more detail by running
drush cr-vvv
Which throws a lot of information about the state of drush
You can also try it with
drush updb -y -vvv
 

Solution

After a long time googling and asking in Drupal user groups (community, whatsapp), finally found the solution with my friend Aldibier and the solution is given by the memory limit of the command line for PHP, that is, the PHP cli
To obtain this information you can use the following command in the console
php -i | grep memory_limit
The output of the above command shows the amount of memory drush is using when executing the instructions, drush needs at least 128Mb
Since it can be determined how much memory is needed, this can be done from the same command line with the following command:
php -d memory_limit=128Mb vendor/drush/drush/drush.php cr

With this instruction the command is executed without problems, so from this conclusion, we must change our amount of memory in /etc/php/8.1/apache/php.ini, looking inside this file for the line memory_limit
If it is the case that it is a shared hosting, the provider must be requested to resize the limit amount of memory.

I hope this information is useful.

Greetings

Secciones
Tags

Contenido Relacionado