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

VSCode keeps pointing to wrong executables especially PHP Executables, works perfectly in regular mac terminal #131534

Closed
theMyth721 opened this issue Aug 24, 2021 · 6 comments
Assignees
Labels
*question Issue represents a question, should be posted to StackOverflow (VS Code)

Comments

@theMyth721
Copy link

theMyth721 commented Aug 24, 2021

Issue Type: Bug

It seems like ever since I upgraded my macos to Big Sur 11.5.2 I have been struggling to use the terminal properly.

I have created this question on stackoverflow: https://stackoverflow.com/questions/68899144/wrong-php-version-executable-in-vscode-terminal-but-works-perfectly-in-mac-termiFatal

I have tried everything, updated the executablePath, the validate.executablePath, completely reinstalled VSCode and done everything, nothing works.

This is a very strange bug as everything works perfectly in the regular terminal.

With PHP for example I have PHP 8.0.9 installed with brew and is in /opt/homebrew/bin/php but VSCode keeps pointing to /usr/bin/php which has the old mac version of php.

When I try to do PHP commands in a symfony project I get the following error:

error: Composer detected issues in your platform: Your Composer dependencies require a PHP version ">= 8.0.0". You are running 7.3.24-(to be removed in future macOS)

When I try to do unit tests in PHPUnit I get the following error:

/usr/bin/php declares an invalid value for PHP_VERSION.
This breaks fundamental functionality such as version_compare().
Please use a different PHP interpreter.

I am banging my head against the wall for days and I am not sure how to set this up properly.
Please do not just answer something generic and close this question without discussion as i have tried everything imaginable

Any advice would be appreciated

VS Code version: Code 1.59.1 (3866c35, 2021-08-19T11:57:20.140Z)
OS version: Darwin arm64 20.6.0
Restricted Mode: No

System Info
Item Value
CPUs Apple M1 (8 x 24)
GPU Status 2d_canvas: enabled
gpu_compositing: enabled
metal: disabled_off
multiple_raster_threads: enabled_on
oop_rasterization: enabled
opengl: enabled_on
rasterization: enabled
skia_renderer: disabled_off_ok
video_decode: enabled
webgl: enabled
webgl2: enabled
Load (avg) 1, 1, 1
Memory (System) 16.00GB (2.52GB free)
Process Argv --crash-reporter-id 6c7a08f1-4f6d-4085-953c-cf5555df1369
Screen Reader no
VM 0%
Extensions (25)
Extension Author (truncated) Version
node-essentials afr 1.1.0
vscode-icontheme-nomo-dark be5 1.3.6
vscode-intelephense-client bme 1.7.1
node-snippets chr 1.3.2
path-intellisense chr 2.4.0
vscode-eslint dba 2.1.23
es7-react-js-snippets dsz 3.1.1
gitlens eam 11.6.0
EditorConfig Edi 0.16.4
vscode-pull-request-github Git 0.29.2
twig-language mbl 0.9.2
dotenv mik 1.0.1
vscode-kubernetes-tools ms- 1.3.3
vscode-typescript-tslint-plugin ms- 1.3.3
vsliveshare ms- 1.0.4673
debugger-for-chrome msj 4.12.12
vscode-jest Ort 4.1.0
vscode-thunder-client ran 1.9.1
fabric8-analytics red 0.3.3
vscode-commons red 0.0.6
vscode-yaml red 0.22.0
ejs-snippets Tao 0.1.0
vscodeintellicode Vis 1.2.14
quokka-vscode Wal 1.0.394
vscode-import-cost wix 2.15.0
A/B Experiments
vsliv368cf:30146710
vsreu685:30147344
python383:30185418
pythonvspyt678:30270856
pythonvspyt602:30300191
vspor879:30202332
vspor708:30202333
vspor363:30204092
pythonvspyt639:30300192
pythontb:30283811
pythonptprofiler:30281270
vshan820:30294714
vstes263cf:30335440
pythondataviewer:30285071
pythonvsuse255:30340121
vscod805cf:30301675
pythonvspyt200:30340761
vscextlangct:30333562
binariesv615:30325510
pythonvssor306:30344512
bridge0708:30335490
pygetstartedc2:30351386
vstre464:30350172
bridge0723:30353136
vsdyn321cf:30356811

@vscodebot
Copy link

vscodebot bot commented Aug 24, 2021

(Experimental duplicate detection)
Thanks for submitting this issue. Please also check if it is already covered by an existing one, like:

@ajlive
Copy link

ajlive commented Sep 1, 2021

I'm having this same issue.

Steps to reproduce

1. Install Homebrew PHP

% brew install php

2. Restart computer

3. Check PHP executable and version in iTerm and Terminal.app

Both have the same output:

% which php
/opt/homebrew/bin/php
% php --version
PHP 8.0.10 (cli) (built: Aug 26 2021 07:11:25) ( NTS )
Copyright (c) The PHP Group
Zend Engine v4.0.10, Copyright (c) Zend Technologies
    with Zend OPcache v8.0.10, Copyright (c), by Zend Technologies

Both apps use the Homebrew executable.

4. Check PHP executable and version in vscode integrated terminal

% which php
/usr/bin/php
% php --version
WARNING: PHP is not recommended
PHP is included in macOS for compatibility with legacy software.
Future versions of macOS will not include PHP.
PHP 7.3.24-(to be removed in future macOS) (cli) (built: Jun 17 2021 21:41:13) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.24, Copyright (c) 1998-2018 Zend Technologies

vscode is using the system PHP.

System

CPUs Apple M1 (8 x 24)
GPU Status 2d_canvas: enabled gpu_compositing: enabled metal: disabled_off multiple_raster_threads: enabled_on oop_rasterization: enabled opengl: enabled_on rasterization: enabled skia_renderer: disabled_off_ok video_decode: enabled webgl: enabled webgl2: enabled
Load (avg) 13, 40, 22
Memory (System) 16.00GB (0.20GB free)
Process Argv --crash-reporter-id 69fea1f3-4a27-4e25-a295-e14beaa5fe30
Screen Reader no
VM 0%

Extensions

Extension Author (truncated) Version
github-markdown-preview bie 0.0.2
markdown-checkbox bie 0.1.3
markdown-emoji bie 0.1.0
markdown-preview-github-styles bie 0.2.0
markdown-yaml-preamble bie 0.0.4
vscode-intelephense-client bme 1.7.1
go gol 0.27.1
vscode-graphql Gra 0.3.18
python ms- 2021.9.1160333636-dev
vscode-pylance ms- 2021.8.4-pre.1
jupyter ms- 2021.8.2031190714
jupyter-keymap ms- 1.0.0
fish-vscode sky 0.2.1
vim vsc 1.21.7
markdown-all-in-one yzh 3.4.0

(1 theme extensions excluded)

A/B Experiments

vsliv695:30137379
vsins829:30139715
vsliv368cf:30146710
vsreu685:30147344
python383:30185418
pythonvspyt602:30291494
vspor879:30202332
vspor708:30202333
vspor363:30204092
pythonvspyt639:30291487
pythontb:30258533
pythonvspyt551cf:30291413
pythonptprofiler:30281269
vshan820:30294714
pythondataviewer:30285072
pythonvsuse255:30319630
vscod805:30301674
pythonvspyt200:30323110
vsccppwt:30312692
pythonvssor306:30340298
bridge0708:30335490
pygetstartedt2:30353727
dockerwalkthru:30348713
bridge0723:30353136
pythonrunftest32cf:30353182
pythonf5test824:30353183
javagetstartedt:30350119
pythonvspyt187cf:30356035
pydsgsc2:30356658

@nlenkowski
Copy link

I'm also having this issue on a fresh install of MacOS 11.5.2 and VSCode 1.59.0 (Universal) on an M1 Mac Mini.

I have various versions of PHP installed via Homebrew and I'm switching between them (linking/unlinking) with the Laravel Valet valet use command.

In the Mac terminal and iTerm2 the currently linked version of PHP is respected, but in the VSCode terminal it is not, it always loads the bundled MacOS PHP instead.

To fix this I am manually exporting the path to the correct PHP in ~/.zshrc, like so:

export PATH=/opt/homebrew/opt/php@7.4/bin:$PATH

This works, but obviously it's a pain as I have to update this path whenever I switch the PHP version.

Anyone have a more permanent fix!?

@theMyth721
Copy link
Author

Yes I have managed to fix it by adding PHP to the path. But this does not seem like a clean solution as you suggested, because whenever we update PHP this needs to be done manually.

VSCode seems to pickup the OpenJDK I have added with Homebrew but somehow not PHP

There should be a cleaner way to tell VSCode to point to the right executable

Why is executablePath & validate.executablePath not working I have no idea

@Tyriar
Copy link
Member

Tyriar commented Sep 2, 2021

See https://code.visualstudio.com/docs/editor/integrated-terminal#_why-are-there-duplicate-paths-in-the-terminals-path-environment-variable-andor-why-are-they-reversed for an explanation and how to fix this issue

@Tyriar Tyriar closed this as completed Sep 2, 2021
@Tyriar Tyriar added the *question Issue represents a question, should be posted to StackOverflow (VS Code) label Sep 2, 2021
@nlenkowski
Copy link

Thanks a ton @Tyriar. Setting "terminal.integrated.inheritEnv": false in VSCode indeed fixed the issue. Sorry for the fuss!

@github-actions github-actions bot locked and limited conversation to collaborators Oct 17, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
*question Issue represents a question, should be posted to StackOverflow (VS Code)
Projects
None yet
Development

No branches or pull requests

5 participants