Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drush uses incorrect PHP version on updatedb command event with prefix in path #6166

Open
devchoosit opened this issue Nov 15, 2024 · 1 comment

Comments

@devchoosit
Copy link

Describe the bug
When many PHP versions are installed
I run command with PHP prefix
But command run drush without PHP version
It run with default PHP version and throw an error

The command "/path/to/site/vendor/bin/drush updatedb:status --yes --strict=0" failed.                                                                          
                                                                                                                                                                                                           
  Exit Code: 255(Unknown error)                                                                                                                                                                            
                                                                                                                                                                                                           
  Working directory:                                                                                                                                                                                       
                                                                                                                                                                                                           
  Output:                                                                                                                                                                                                  
  ================                                                                                                                                                                                         
                                                                                                                                                                                                           
                                                                                                                                                                                                           
  Error Output:                                                                                                                                                                                            
  ================                                                                                                                                                                                         
  PHP Warning:  Module "curl" is already loaded in Unknown on line 0                                                                                                                                       
  Composer detected issues in your platform:                                                                                                                                                               
                                                                                                                                                                                                           
  Your Composer dependencies require a PHP version ">= 8.2.0". You are running 8.1.30.                                                                                                                     
                                                                                                                                                                                                           
  PHP Fatal error:  Composer detected issues in your platform: Your Composer dependencies require a PHP version ">= 8.2.0". You are running 8.1.30. in /path/to/site/vendor/composer/platfo  
  rm_check.php on line 24  

I tried to specify php prefix in drush-script version but use space doesn't work

The command "'/usr/bin/php8.2 /path/to/site/vendor/bin/drush.php' updatedb:status --yes --strict=0" failed.  
                                                                                                                                                         
  Exit Code: 127(Command not found)                                                                                                                      
                                                                                                                                                         
  Working directory:                                                                                                                                     
                                                                                                                                                         
  Output:                                                                                                                                                
  ================                                                                                                                                       
                                                                                                                                                         
                                                                                                                                                         
  Error Output:                                                                                                                                          
  ================                                                                                                                                       
  sh: 1: /usr/bin/php8.2 /path/to/site/vendor/bin/drush.php: not found 

To Reproduce

  • Install drupal with many php versions
  • Use different php than default version
  • Override drush-script in config drush-script: '/usr/bin/php8.2 /path/to/site/vendor/bin/drush.php'

Expected behavior
Drush should run with php prefix as command set in terminal

Actual behavior
Prefix php can't be set and Drush use default php version

Workaround
In Process Manager src/SiteAlias/ProcessManager.php
when drush is set on first on args

// The executable is always 'drush' (at some path or another)
        array_unshift($args, $drushScript);

If space is set in drush path,it whould explode in array and set in args in different keys

// The executable is always 'drush' (at some path or another)
$drushArray = explode(' ', $drushScript);
foreach (array_reverse($drushArray) as $drush) {
  array_unshift($args, $drush);
}

System Configuration

Q A
Drush version? 13.3.3
Drupal version? 10.3
PHP version 8.3
OS? Linux
@weitzman
Copy link
Member

Drush doesn't select a php - your operating does that using the PATH env variable. This happenned to work before 13.3.3 but no longer does. See the Note at https://www.drush.org/latest/install/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants