Skip to content

Drush ProcessManager does not respect the PHP version Drush was invoked with #6273

Closed as not planned
@echernyavskiy

Description

@echernyavskiy

Describe the bug
When running dependent commands internally (like core:status before sql:sync), ProcessManager does not respect the PHP version Drush has originally been invoked with.

To Reproduce
Given two PHP versions installed in the system, e.g. 8.2 (the default, symlinked to /usr/bin/php) and 8.3, execute Drush sql-sync like /usr/bin/php8.3 ./vendor/bin/drush.php sql:sync ...

Expected behavior
Drush records the PHP binary it was invoked with, and re-uses it for any subsequent internal invocations.

Actual behavior
The internal invocation of core:status dependent command is made using the default version of PHP (8.2 in this example):

 /usr/bin/php8.3 /var/www/builds/my-dev-app.com/vendor/bin/drush.php --root="/var/www/builds/my-dev-app.com" --uri="https://my-dev-app.com" --yes sql:sync @app.prod @self --create-db --debug --verbose
 [preflight] Config paths: /var/www/builds/my-dev-app.com/vendor/drush/drush/drush.yml
 [preflight] Alias paths: /var/www/builds/my-dev-app.com/web/drush/sites,/var/www/builds/my-dev-app.com/drush/sites
 [preflight] Commandfile search paths: /var/www/builds/my-dev-app.com/vendor/drush/drush/src,/var/www/builds/my-dev-app.com/drush
 [info] Starting bootstrap to none [1.68 sec, 19.71 MB]
 [info] Drush bootstrap phase 0 [1.68 sec, 19.71 MB]
 [info] Try to validate bootstrap phase 0 [1.68 sec, 19.71 MB]
 [info] Executing: env PATH=/bin:/usr/bin:/usr/local/bin DRUPAL_ENVIRONMENT=development /var/www/builds/my-prod-app.com/vendor/bin/drush core:status --fields=db-name --format=json --create-db --verbose --yes -vvv --strict=0 --uri=https://my-prod-app.com [1.73 sec, 20.74 MB]
 [info] Executing: /var/www/builds/my-dev-app.com/vendor/bin/drush core:status --fields=db-name --format=json --create-db --verbose --yes -vvv --strict=0 --uri=https://my-dev-app.com [4.79 sec, 20.77 MB]

In SiteProcess.php line 214:
                                                                                                                                                                                                           
  [Symfony\Component\Process\Exception\ProcessFailedException]                                                                                                                                             
  The command "/var/www/builds/my-dev-app.com/vendor/bin/drush core:status --fields=db-name --format=json --create-db --verbose --yes -vvv --strict=0 --u  
  ri=https://my-dev-app.com" failed.                                                                                                                       
                                                                                                                                                                                                           
  Exit Code: 255(Unknown error)                                                                                                                                                                            
                                                                                                                                                                                                           
  Working directory:                                                                                                                                                                                       
                                                                                                                                                                                                           
  Output:                                                                                                                                                                                                  
  ================                                                                                                                                                                                         
                                                                                                                                                                                                           
                                                                                                                                                                                                           
  Error Output:                                                                                                                                                                                            
  ================                                                                                                                                                                                         
  Composer detected issues in your platform:                                                                                                                                                               
                                                                                                                                                                                                           
  Your Composer dependencies require a PHP version ">= 8.3.0". You are running 8.2.27.                                                                                                                     
                                                                                                                                                                                                           
  PHP Fatal error:  Composer detected issues in your platform: Your Composer dependencies require a PHP version ">= 8.3.0". You are running 8.2.27. in /var/www/builds/my-dev-app.com/vendor/composer/platform_check.php on line 22

Workaround
N/A

System Configuration

Q A
Drush version? 13.5.1
Drupal version? 11.x
PHP version 8.x
OS? Linux

Additional information
N/A

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions