Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Charrua's avatar

Updated to Mac OS Monterrey and better-phpunit stopped working on escode

Hello, after upgrading to Mac OS Monterrey the extension by calebporzio.better-phpunit stopped working.

In my terminal I can run PHP scripts and I have installed PHP 7.4 with brew.

➜  php -v                              
PHP 7.4.27 (cli) (built: Dec 16 2021 18:14:46) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
    with Zend OPcache v7.4.27, Copyright (c), by Zend Technologies

I can run tests by using ./vendor/bin/phpunit without any issues, but when trying to use the vscode extension to test some method using cmd+k cmd+r keys I got the error:

> Executing task: /xxxxxx/vendor/bin/phpunit /xxxxxx/tests/Feature/Admin/Users/ShowUserTest.php --filter '^.*::can_see_a_button_to_add_enrollment_if_is_student( .*)?$' <

env: php: No such file or directory
The terminal process "/bin/zsh '-c', '/xxxxxx/vendor/bin/phpunit /xxxxxx/tests/Feature/Admin/Users/ShowUserTest.php --filter '^.*::can_see_a_button_to_add_enrollment_if_is_student( .*)?$''" terminated with exit code 127.

The tasks will reuse the terminal, press any key to close it.

Is like the task that runs the better-phpunit extension doesn't find php.

UPDATE: I have made some more tests, if I execute the command in the vscode terminal it returns ok, so php is found in the integrated terminal.

I have created a vscode task to see if the problem was there and YES, there is some problem when executing a task with a php command.

The first task I've created was only to see if php was found:

{
    "version": "2.0.0",
    "tasks": [
			"label": "Test find PHP",
			"type": "shell",
			"command": "which php",
			"group": "test",
			"presentation": {
				"reveal": "always"
			},
			"problemMatcher": []
		}
	]
}

The return was:

> Executing task: which php <

php not found
El proceso del terminal "/bin/zsh '-c', 'which php'" finalizó con el código de salida 1.

Antoher test was to see if the ~/.zshrc file was loaded in the terminal used by the tasks, and it was the same as the integrated terminal used by vscode. So I'm lost here...

Any ideas?

0 likes
1 reply
Sofia's avatar

I know this is a year old, but no one answered and this question/tests pointed me in the right direction of resolving the same issue.

When running env via a task vs. the integrated terminal, the shell being used was the same, but the PATH variable was different. It turns out that the paths specified in ~/.zprofile were being used over the ~/.zshrc ones when running the task and I had some old binary paths in there that were otherwise ignored by everything else.

Please or to participate in this conversation.