Local Community

Wrong PHP version in site shell

Issue Summary

I open the site shell. It says: PHP: 7.3.5. When I type php -v it says PHP 7.4.16. I am expecting to see PHP 7.3.5.

Troubleshooting Questions

  • This happens for all sites, even ones I create from scratch with PHP 7.3.
  • Other than that everything seems to work fine.

Replication

Create a new site with PHP 7.3, open site shell, type php -v.

System Details

  • Local v 5.10.1+5267
  • macOS 11.2.3 (20D91)

local-lightning.log (261.7 KB)

What are the results of which php ?

/usr/local/opt/php@7.4/bin/php

Can you screenshot when you open a site shell?

sure, here you go!

What does the following command show?

echo $PATH | tr ':' "\n"
/usr/local/opt/php@7.4/sbin
/usr/local/opt/php@7.4/bin
/usr/local/opt/helm@2/bin
/usr/local/opt/mysql@5.7/bin
/Users/<foobar>/google-cloud-sdk/bin
/Applications/Local.app/Contents/Resources/extraResources/bin/composer/posix
/Applications/Local.app/Contents/Resources/extraResources/bin/wp-cli/posix
/Applications/Local.app/Contents/Resources/extraResources/lightning-services/php-7.3.5+10/bin/darwin/bin
/Users/<foobar>/Library/Application Support/Local/lightning-services/mysql-5.7.28+4/bin/darwin/bin
/usr/local/opt/php@7.4/sbin
/usr/local/opt/php@7.4/bin
/usr/local/opt/helm@2/bin
/usr/local/opt/mysql@5.7/bin
/Users/<foobar>/google-cloud-sdk/bin
/Users/<foobar>/.nvm/versions/node/v10.23.3/bin
/usr/local/bin
/usr/bin
/bin
/usr/sbin
/sbin
/usr/local/MacGPG2/bin
/Applications/Wireshark.app/Contents/MacOS
/Users/<foobar>/.composer/vendor/bin
/Users/<foobar>/.composer/vendor/bin

You must have something in you .zshrc file or .bashrc that causes those paths to reload in the beginning of the PATH with each session.

You might need to load them to the end of the PATH not he beginning.

Something similar to this might also work,

1 Like

Hi, thank you for your support so far! I added this to my .zshrc: typeset -U PATH, this prevents the path values from appearing multiple times. Now echo $PATH | tr ':' "\n" returns

/usr/local/sbin
/usr/local/opt/mysql@5.7/bin
/usr/local/opt/helm@2/bin
/usr/local/opt/php@7.4/bin
/usr/local/opt/php@7.4/sbin
/Applications/Local.app/Contents/Resources/extraResources/bin/composer/posix
/Applications/Local.app/Contents/Resources/extraResources/bin/wp-cli/posix
/Applications/Local.app/Contents/Resources/extraResources/lightning-services/php-7.3.5+10/bin/darwin/bin
[...]

The Local.app versions are still being ignored. I didn’t quite follow what you meant in that other thread. Reinstall homebrew in a different directory?

Adding homebrew php at the end of the path variables fixed it.

typeset -U path
path=(/usr/local/sbin
      $path
      /usr/local/opt/mysql@5.7/bin
      /usr/local/opt/helm@2/bin
      /usr/local/opt/php@7.4/bin
      /usr/local/opt/php@7.4/sbin
      $HOME/.composer/vendor/bin)
export PATH
2 Likes

This topic was automatically closed 36 hours after the last reply. New replies are no longer allowed.