I am facing this issue in Visual Studio Code. I have already tried reinstalling the phpcs extension but still facing this issue.
Unable to locat
I had this same error and I noticed that phpcs was working from the command line but not working in vscode. I had to read the linter.js file (of the vscode extension) to see where this error is coming from. This fix is more of an info.
So, to fix this: First, run the command phpcs --version
and check if the command does not print any warning or error before outputting a line similar to PHP_CodeSniffer version x.x.x (stable) by Squiz (HTTP://www.squiz.net)
.
If any error or warning (usually unrelated to phpcs) is thrown before the line showing the phpcs version, please go fix that warning or error first. According to linter.js, it expects that the first output (when phpcs.bat is executed) must start with the PHP_CodeSniffer version
string. Thus, If anything should print before the PHP_CodeSniffer version ...., then it throws the error.
So, You MUST fix any warning or error printed before the phpcs version if you want phpcs to work in VSCode. I hope this fix works for you. cheers!