Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Checklist:
- searched issue queue multiple times with various search options, filters
- Rechecked on HEAD drush
- Debug output
- drush status
- Checked drush topic, FAQ etc.
I am unable to get drush to use a different php binary when specifying the --php option:
Alans-MacBook-Pro:src alan$ drush --php=/Applications/acquia-drupal/php/bin/php -d ev 'echo phpversion() . "\n"'
Bootstrap to phase 0. [0 sec, 3.26 MB] [bootstrap]
Drush bootstrap phase : _drush_bootstrap_drush() [0.01 sec, 3.48 MB] [bootstrap]
Cache HIT cid: 5.0-dev-commandfiles-0-d10ae5a6475efaedc9c59c8e61a8894d [0.01 sec, 3.49 MB] [debug]
Found command: php-eval (commandfile=core) [0.03 sec, 7.51 MB] [bootstrap]
5.3.6
Command dispatch complete [0.03 sec, 7.52 MB] [notice]
Peak memory usage was 9.03 MB [0.03 sec, 7.53 MB] [memory]
Alans-MacBook-Pro:src alan$ drush --php=/usr/bin/php -d ev 'echo phpversion() . "\n"'
Bootstrap to phase 0. [0 sec, 3.25 MB] [bootstrap]
Drush bootstrap phase : _drush_bootstrap_drush() [0.01 sec, 3.48 MB] [bootstrap]
Cache HIT cid: 5.0-dev-commandfiles-0-d10ae5a6475efaedc9c59c8e61a8894d [0.01 sec, 3.49 MB] [debug]
Found command: php-eval (commandfile=core) [0.03 sec, 7.51 MB] [bootstrap]
5.3.6
Command dispatch complete [0.03 sec, 7.52 MB] [notice]
Peak memory usage was 9.03 MB [0.04 sec, 7.53 MB] [memory]
Alans-MacBook-Pro:src alan$ /usr/bin/php -v
PHP 5.3.6 with Suhosin-Patch (cli) (built: Jun 16 2011 22:26:57)
Copyright (c) 1997-2011 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2011 Zend Technologies
Alans-MacBook-Pro:src alan$ /Applications/acquia-drupal/php/bin/php -v
PHP 5.2.17 (cli) (built: Jun 30 2011 12:12:11)
Copyright (c) 1997-2010 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2010 Zend Technologies
Alans-MacBook-Pro:src alan$ drush status
PHP configuration : /private/etc/php.ini
Drush version : 5.0-dev
Drush configuration :
Drush alias files :
Reading through the initial bash script (drush), I don't see anywhere where this --php option would be handled, so it almost suggests that this may be a deprecated option, not removed from drush help. Some internals still use it though (eg to specify the interpreter to subcommands).
i can force drush to use a different binary by setting the DRUSH_PHP environment variable.
I can probably supply a patch to make it honour the option, but wanted to check first of all that this is not by design.
Comment | File | Size | Author |
---|---|---|---|
#10 | drush_php_env.diff | 586 bytes | moshe weitzman |
#8 | remove_php_in_aliases.diff | 720 bytes | moshe weitzman |
Comments
Comment #1
greg.1.anderson CreditAttribution: greg.1.anderson commentedYou are correct; the bash drush script uses --php and --php-options to tell the php drush script which php command and options to use when re-launching drush directly. The bash drush script currently does not parse or act on command line options at all.
It seems sensible to have the script check for these options. What do other maintainers think about adding cli option parsing to the drush script?
Comment #2
greg.1.anderson CreditAttribution: greg.1.anderson commentedI sort of think we should leave the drush script as it is, and mark --php and --php-options 'hidden' to avoid confusion (keep them out of help). The environment variable should be documented in drush topic or global options help.
Comment #3
Alan Evans CreditAttribution: Alan Evans commentedFor what it's worth, I would have found the option of switching the php binary useful earlier today, but to be honest, setting the environment variable is just as easy.
It does still strike me that the option could cause some inconsistency if you explicitly pass the --php option on the command line and it happens not to match the environment variable or `which php` : you could end up running the initial command with the default php interpreter and all subcommands with a different one that you specified with the --php option. I can't imagine a situation where that's good. But then again, if you hide the --php option completely and only use the environment variable, then you can ensure consistency that way.
If you think this isn't an issue then I'm happy with the idea of hiding it and adding docs on the env variable.
Comment #4
moshe weitzman CreditAttribution: moshe weitzman commentedNot sure what we should do here, if anything. --php-options is not hidden at this time.
Comment #5
greg.1.anderson CreditAttribution: greg.1.anderson commentedI don't know if marking php-options hidden is the right thing to do, because it does work if you put them in your alias file. Kind of obscure...
Comment #6
moshe weitzman CreditAttribution: moshe weitzman commentedi removed --php-options from the readme.txt. readme already mentions DRUSH_PHP enivonment variable and php and php-options remain documented in example site aliases file.
Comment #8
moshe weitzman CreditAttribution: moshe weitzman commentedActually, I think we should remove the 'php' item from example.aliases.drushrc.php. One might read it and think that Drush will initially use the specified php when using a remote alias. Thats not so - the only thing that affects which php is initially used here is the DRUSH_PHP environment variable. Drush site aliases currently provide no way to control which PHP gets used, sadly.
Patch attached.
Comment #9
greg.1.anderson CreditAttribution: greg.1.anderson commentedActually, we are almost there with this code in backend.inc:
The problem is that drush_build_drush_command will ignore $php, favoring the 'drush' script instead, when array_key_exists('remote-host', $site_record) evaluates to true. We could easily change this behavior if we forced this parameter to FALSE when the site record provides both a php and a drush path (since calling drush via php requires the full path to the drush script, and this might not be the same on the remote machine as it is on the local machine).
Some additional work needs to be done to determine if php-options can really be passed through cleanly still; I'm not sure that this still works right.
If we just yank the documentation, you should also remove php-options from the list (unless testing confirms that it's already working correctly.)
Comment #10
moshe weitzman CreditAttribution: moshe weitzman commentedYou gave me an idea. Attached 1 line patch does the trick for me, since I am not pointing to drush.php explicitly. I didn't even realize that we supported that.
Comment #11
greg.1.anderson CreditAttribution: greg.1.anderson commentedI don't have time to test, but #10 looks really good to me.
Comment #12
moshe weitzman CreditAttribution: moshe weitzman commentedCommitted, with slight update to example.aliases file.