3

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?

Daniel P.
  • 184
  • 1
  • 3
  • 16
  • "the extension Better PHPUnit stopped working" - what does that mean? Is there any error message given? If VSCode uses a diffent path setting, why not correct that? – Nico Haase Feb 14 '22 at 10:48
  • @NicoHaase the extension has some tasks to execute the tests with keyboard keys, when using those tasks the error I see in console is `env: php: No such file or directory`. But if I execute the command myself from the vscode console they work fine. – Daniel P. Feb 14 '22 at 12:39

2 Answers2

2

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

GTP
  • 51
  • 5
  • 2
    I have tried this but it doesn't work on my end :( vscode sees the `php.validate.executablePath` but when executing the task the console launched doesn't see it. – Daniel P. Feb 20 '22 at 16:56
0

I'm running into the same issue off and on with macOS. I was able to figure this out with the help of this comment.

"terminal.integrated.profiles.osx": {
    "zsh": {
        "path": "/bin/zsh -l",
        "args": []
    },
}

Unfortunately not solving my issue with a specific extension, but I could make some tasks now.

John
  • 1
  • 3