vscode-php-cs-fixer icon indicating copy to clipboard operation
vscode-php-cs-fixer copied to clipboard

PHP CS Fixer: executablePath not found, please check your settings. It will set to built-in php-cs-fixer.phar. Try again!

Open ghnp5 opened this issue 3 years ago • 3 comments

Hey

On Windows, I don't seem to be able to get this to work on a multi-folder workspace, unless I use the absolute path, but then it's not guaranteed to work on other people's machines.

Say I have this setup:

	"folders": [
		{
			"path": "."
		},
		{
			"path": "..\\common-web"
		}
	],

And the MyProject.code-workspace file is inside the main repo, myproject.

If I open VSCode, and the file that is open is, say, common.php inside the ..\common-web folder, then executablePath not found for anything I try, except if I hardcode my full path.

Examples:

"php-cs-fixer.executablePath": "${workspaceFolder}\\vendor\\bin\\php-cs-fixer.bat",

=>

"syscall": "spawn f:\Files\Git\common-web\vendor\bin\php-cs-fixer.bat", "path": "f:\Files\Git\common-web\vendor\bin\php-cs-fixer.bat",

--

"php-cs-fixer.executablePath": "${workspaceFolder}\\..\\myproject\\vendor\\bin\\php-cs-fixer.bat",

=>

"syscall": "spawn myproject\vendor\bin\php-cs-fixer.bat", "path": "myproject\vendor\bin\php-cs-fixer.bat",

--

"php-cs-fixer.executablePath": "${workspaceFolder}/../myproject/vendor/bin/php-cs-fixer.bat",

=>

"syscall": "spawn myproject\vendor\bin\php-cs-fixer.bat", "path": "myproject\vendor\bin\php-cs-fixer.bat",

--

"php-cs-fixer.executablePath": "../myproject/vendor/bin/php-cs-fixer.bat",

=>

"syscall": "spawn ..\myproject\vendor\bin\php-cs-fixer.bat", "path": "..\myproject\vendor\bin\php-cs-fixer.bat",

--

I've also tried giving names to the folders:

	"folders": [
		{
			"path": ".",
			"name": "MyProject"
		},
		{
			"path": "..\\common-web",
			"name": "CommonWeb"
		}
	],
"php-cs-fixer.executablePath": "${workspaceFolder:MyProject}\\vendor\\bin\\php-cs-fixer.bat",

=>

"syscall": "spawn ${workspaceFolder:MyProject}\vendor\bin\php-cs-fixer.bat", "path": "${workspaceFolder:MyProject}\vendor\bin\php-cs-fixer.bat",

--

I assume the same issue would be with php-cs-fixer.config, which is located in myproject folder, but I don't want to hardcode my machine's full path.

--

Other extensions seem to work well with multi-folder.

For example, PHP Sniffer itself has no problem with just this:

	"phpSniffer.executablesFolder": "..\\myproject\\vendor\\bin\\",
	"phpSniffer.run": "onSave",
	"phpSniffer.standard": "..\\myproject\\phpcs.xml",

Thanks!

ghnp5 avatar Dec 09 '22 22:12 ghnp5

not support related path, must absolute path

junstyle avatar Dec 10 '22 02:12 junstyle

Thank you.

However, to make it work best with different machines and team developers, it would be nice to support relative paths or named filters like ${workspaceFolder:MyProject}.

Regards

ghnp5 avatar Dec 10 '22 16:12 ghnp5

For me this works with the current version. I'm on Windows 11 with WSL Ubuntu.

"php-cs-fixer.executablePath": "${workspaceFolder}/packages/laravel/vendor/bin/php-cs-fixer",
"php-cs-fixer.config": "${workspaceFolder}/packages/laravel/.php-cs-fixer.php"

jrson83 avatar May 10 '24 19:05 jrson83