SSH uses macOS PHP instead of the Local PHP

Bug Summary

When I open the Site Shell, I see it’s using PHP 8.1 (what I have on my macOS locally) instead of PHP 8.0.22 (what I have on the Local site).

Steps to reproduce

  1. PHP 8.0.22 is set on my local site
  2. Click “Open site shell” from below site name on details view or right click on site and choose that menu option
  3. Type php -v
  4. See PHP 8.1.9 (cli) (built: Aug 4 2022 14:00:20) (NTS)

Environment Info

  • macOS 12.5.1
  • nginx / PHP 8.0.22 / MySQL 8.0.16 / WP 6.0.2
  • Local 6.4.3+6116

Supporting info

{"thread":"main","class":"Process","process":"mysql","level":"warn","message":"2022-10-08T00:08:13.411323Z 0 [System] [MY-010116] [Server] %%resourcesPath%%/lightning-services/mysql-8.0.16+6/bin/darwin/bin/mysqld (mysqld 8.0.16) starting as process 93769","timestamp":"2022-10-08T00:08:13.663Z"}
{"thread":"main","class":"Process","process":"mysql","level":"warn","message":"2022-10-08T00:08:13.414599Z 0 [Warning] [MY-013243] [Server] --character-set-server: The character set UTF8MB3 is deprecated and will be removed in a future release. Please consider using UTF8MB4 instead.","timestamp":"2022-10-08T00:08:13.663Z"}
{"thread":"main","class":"Process","process":"mysql","level":"warn","message":"2022-10-08T00:08:13.415144Z 0 [Warning] [MY-010159] [Server] Setting lower_case_table_names=2 because file system for %%site.runData%%/mysql/data/ is case insensitive","timestamp":"2022-10-08T00:08:13.663Z"}
{"thread":"main","class":"Process","process":"mysql","level":"warn","message":"2022-10-08T00:08:13.652192Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed.","timestamp":"2022-10-08T00:08:13.663Z"}
{"thread":"main","class":"Process","process":"mysql","level":"warn","message":"2022-10-08T00:08:13.662377Z 0 [System] [MY-010931] [Server] %%resourcesPath%%/lightning-services/mysql-8.0.16+6/bin/darwin/bin/mysqld: ready for connections. Version: '8.0.16'  socket: '%%site.runData%%/mysql/mysqld.sock'  port: 10003  MySQL Community Server - GPL.","timestamp":"2022-10-08T00:08:13.664Z"}
{"thread":"main","class":"SiteProvisionerService","level":"warn","message":"Unable to flush permalinks","timestamp":"2022-10-08T00:08:17.111Z"}
{"thread":"main","class":"Process","process":"mysql","level":"warn","message":"2022-10-09T19:42:00.771211Z 0 [System] [MY-010116] [Server] %%resourcesPath%%/lightning-services/mysql-8.0.16+6/bin/darwin/bin/mysqld (mysqld 8.0.16) starting as process 30399","timestamp":"2022-10-09T19:42:01.026Z"}
{"thread":"main","class":"Process","process":"mysql","level":"warn","message":"2022-10-09T19:42:00.773413Z 0 [Warning] [MY-013243] [Server] --character-set-server: The character set UTF8MB3 is deprecated and will be removed in a future release. Please consider using UTF8MB4 instead.","timestamp":"2022-10-09T19:42:01.026Z"}
{"thread":"main","class":"Process","process":"mysql","level":"warn","message":"2022-10-09T19:42:00.773964Z 0 [Warning] [MY-010159] [Server] Setting lower_case_table_names=2 because file system for %%site.runData%%/mysql/data/ is case insensitive","timestamp":"2022-10-09T19:42:01.026Z"}
{"thread":"main","class":"Process","process":"mysql","level":"warn","message":"2022-10-09T19:42:01.016199Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed.","timestamp":"2022-10-09T19:42:01.027Z"}
{"thread":"main","class":"Process","process":"mysql","level":"warn","message":"2022-10-09T19:42:01.025965Z 0 [System] [MY-010931] [Server] %%resourcesPath%%/lightning-services/mysql-8.0.16+6/bin/darwin/bin/mysqld: ready for connections. Version: '8.0.16'  socket: '%%site.runData%%/mysql/mysqld.sock'  port: 10003  MySQL Community Server - GPL.","timestamp":"2022-10-09T19:42:01.027Z"}
{"thread":"main","class":"SiteProvisionerService","level":"warn","message":"Unable to flush permalinks","timestamp":"2022-10-09T19:42:01.437Z"}
{"thread":"main","class":"AddonInstallerService","level":"error","stack":"Error: Add-on already exists.\n    at AddonInstallerService.<anonymous> (%%appPath%%/main/addons/AddonInstallerService.js:1:7706)\n    at Generator.next (<anonymous>)\n    at i (%%appPath%%/main/addons/AddonInstallerService.js:1:742)","message":"Add-on already exists.","timestamp":"2022-10-09T19:44:06.511Z"}
{"thread":"main","reason":{"errno":-66,"syscall":"rename","code":"ENOTEMPTY","path":"/var/folders/4x/wt2tybs10zx0h2xp4lj54rgc0000gn/T/local-0VfAULGhZ/package","dest":"%%userDataPath%%/addons/local-tableplus"},"p":{},"eventId":"d6f7de760e15415fa5f6438d36361879","level":"warn","message":"Unhandled Rejection.","timestamp":"2022-10-09T19:44:06.520Z"}

Hey @sc0ttkclark – this is definitely a part of Local I’d love to make more reliable!

My gut tells me this is related to the $PATH variable, and how the shell is started.

As a test, can you give a little more info about how your terminal is set up?

  • What shell are you using?
  • What does the $PATH variable look like?

You should be able to get that data by opening a site shell from Local, and then running these two commands (note that I’m not just echoing the $PATH var, mostly because I find it easier to view as a collection of lines)

echo $SHELL
echo $PATH | tr ':' '\n'

Here’s what my shell looks like within a Local site’s shell:

Because you mention that the shell is using PHP from homebrew instead of Local, I’m guessing that the homebrew lines will be “higher” (in my screenshot, note that /opt/homebrew/bin is below the Local site’s bin entries)

If that is the case, you might consider moving any homebrew related config from the .zshrc file to the .zprofile file. The .zprofile file is only loaded once when you log into the computer (so you’ll need to logout and log back in if you change that value) but I find that it’s a good place to put homebrew config because the tools I tend to install via brew are good defaults, but sometimes I want to override them.

Php is a good example. I like having a general PHP version system wide, via homebrew, but in some cases, I want a more specific version for a specific site, so I let Local override that. Here’s a screenshot to help visualize what I have in .zprofile

Hope that helps zero in on what you have, but I’m still curious about your shell configuration because we might be able to improve Local to be more flexible around these sorts of configuration things.