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

WP CLI ignores current project' PHP version #5464

Closed
2 tasks done
zzap opened this issue Nov 2, 2020 · 4 comments
Closed
2 tasks done

WP CLI ignores current project' PHP version #5464

zzap opened this issue Nov 2, 2020 · 4 comments
Labels

Comments

@zzap
Copy link
Contributor

zzap commented Nov 2, 2020

Bug Report

In my local setup I use different PHP versions per project and can switch versions inside the project but default PHP version for my system is 8.0.0RC3.

However, when I'm inside the project, WP CLI ignores its specified PHP version and use the default one.

Here is PHP info for one of projects:
local-php

And here is WP CLI info in the root of that project.

$ wp cli info
OS:     Linux 5.4.0-52-generic #57-Ubuntu SMP Thu Oct 15 10:57:00 UTC 2020 x86_64
Shell:  /bin/bash
PHP binary:     /usr/bin/php8.0
PHP version:    8.0.0RC3
php.ini used:   /etc/php/8.0/cli/php.ini
WP-CLI root dir:        phar://wp-cli.phar/vendor/wp-cli/wp-cli
WP-CLI vendor dir:      phar://wp-cli.phar/vendor
WP_CLI phar path:       /home/milana/www/developerka.loc
WP-CLI packages dir:    /home/milana/.wp-cli/packages/
WP-CLI global config:   /home/milana/.wp-cli/config.yml
WP-CLI project config:
WP-CLI version: 2.4.0

Is this expected behavior for WP CLI or is it a bug?

@thefrosty
Copy link

PHP versions can differ from source to command line (CLI Interpreter).

@zzap
Copy link
Contributor Author

zzap commented Nov 23, 2020

Yes, I ended up removing PHP8.0 from my system. It's now on 7.4.12 and WP-CLI works as expected.

@thefrosty
Copy link

If you manage PHP locally via brew like I do, check out brew-php-switcher

@schlessera
Copy link
Member

Indeed, often times switching PHP version only switches the version used via the web server. The version used for WP-CLI is the cli SAPI that happens to be found first in the environment's $PATH variable. You can adapt this via different mechanisms, but they all involve doing a change the CLI environment level.

This is expected and just the way PHP CLI tools work, so closing this for now. Feel free to ping me in #cli on Slack if you need further assistance.

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

No branches or pull requests

3 participants