0

I'm trying to run drush for a Drupal 10 project in PHP 8.1 while default PHP still being set to 8.0. What I did was to create a drush81 which basically runs something like

env DRUSH_PHP=/usr/bin/php8.1 /usr/bin/php8.1 vendor/bin/drush

When I now run the following, they all say I'm using 8.1:

drush81 ev "print phpversion();"
# 8.1.16
drush81 ev "print PHP_VERSION_ID;"
# 80116
drush81 ev "print php_ini_loaded_file();"
# /etc/php/8.1/cli/php.ini

But when I run drush81 updb, I get this error:

Composer detected issues in your platform:

Your Composer dependencies require a PHP version ">= 8.1.0". You are running 8.0.28.

PHP Fatal error: Composer detected issues in your platform: Your Composer dependencies require a PHP version ">= 8.1.0". You are running 8.0.28. in /var/staging/training-d10/vendor/composer/platform_check.php on line 24

Having a look at platform_check.php it checks this:

if (!(PHP_VERSION_ID >= 80100)) {
    $issues[] = 'Your Composer dependencies require a PHP version ">= 8.1.0". You are running ' . PHP_VERSION . '.';
}

Any ideas why this might be?

I tried to tell composer to use a different PHP version by replacing the binary with a script (/usr/bin/php8.1 /usr/local/bin/composer-bin "$@") but that didn't help either.

mpj
  • 3
  • 4
  • Symlink /usr/bin/php8.1 as /usr/bin/php8.1-bin/php , add /usr/bin/php8.1-bin in front of PATH `env PATH="/usr/bin/php8.1-bin:$PATH" /usr/bin/php8.1 vendor/bin/drush` and that process then should run php8.1 as php so should composer. – hakre Mar 17 '23 at 21:37
  • Thanks, but this also makes php8.1 the default version. Running `php -v` returns 8.1 – mpj Apr 20 '23 at 07:04

0 Answers0