'Tasks: env: php: No such file or directory
I have updated to Mac OS Monterrey and the extension Better PHPUnit stopped working. This extension runs vscode tasks to make the output in colors, etc.
The error I got when running the tasks is env: php: No such file or directory. If I run the command in the console without using the task, all runs as it should, without any issues.
So investigating and trying to isolate the problem, I have created a task inside VSCODE and seems that the terminal used for tasks is picking up some other $PATH so php is not found.
I have installed PHP using Homebrew. I can execute scripts without any issue BUT when I run echo $PATH inside a task the output is different that when I run the same command in an integrated terminal.
The task I'm using to test is:
{
"version": "2.0.0",
"tasks": [
{
"label": "Run test",
"type": "shell",
"command": "echo $PATH",
"group": "test",
"presentation": {
"reveal": "always"
},
"problemMatcher": []
}
]
}
The output:
> Executing task: echo $PATH <
/usr/bin:/bin:/usr/sbin:/sbin
And if I run the command echo $PATH in an integrated terminal I get:
/Users/xxx/.nvm/versions/node/v15.5.0/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/share/dotnet:~/.dotnet/tools:/Users/xxx/.composer/vendor/bin
Any ideas?
Solution 1:[1]
I encountered env: php: No such file or directory issue after updating brew on my mac and I followed these steps below to resolve it
Step 1:
I ran which php on my terminal to get the path to php and then opened vscode settings
(Code -> Preferences -> Settings)
Step 2:
Click PHPUnit configuration under User and add the copied path to the input box labeled Phpunit: PHP
(mine happened to be blank)
In your case, you can click Edit in settings.json under Extensions > PHP > Validate : Executable Path and paste the copied php path to php.validate.executablePath
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
