vscode-phpcs: Unable to locate phpcs
Hello,
I tried to install the phpcs plugin for Visual Studio Code but I keep getting phpcs: Unable to locate phpcs. Please add phpcs to your global path or use composer depency manager to install it in your project locally.
message. I can access phpcs
from the Command Line, it is available globally in the PATH
.
The PATH
on my device is following:
PATH=C:\Program Files (x86)\iis express\PHP\v5.6;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Skype\Phone\;C:\Program Files\Microsoft SQL Server\120\Tools\Binn\;C:\Program Files\Microsoft SQL Server\130\Tools\Binn\;C:\Program Files (x86)\Windows Kits\10\Windows Performance Toolkit\;C:\Program Files\Git\cmd;C:\Program Files\Microsoft\Web Platform Installer\;C:\Program Files (x86)\Microsoft VS Code\bin;C:\Program Files\nodejs\;C:\Users\hajek\.dnx\bin;C:\Program Files (x86)\Microsoft VS Code\bin;C:\Users\hajek\AppData\Roaming\npm
I also tried adding phpcs.bat
to the PATH
directly, but it didn’t change anything (not even after restart). The resulting PATH
was like this:
PATH=C:\Program Files (x86)\iis express\PHP\v5.6;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Skype\Phone\;C:\Program Files\Microsoft SQL Server\120\Tools\Binn\;C:\Program Files\Microsoft SQL Server\130\Tools\Binn\;C:\Program Files (x86)\Windows Kits\10\Windows Performance Toolkit\;C:\Program Files\Git\cmd;C:\Program Files\Microsoft\Web Platform Installer\;C:\Program Files (x86)\Microsoft VS Code\bin;C:\Program Files\nodejs\;C:\Users\hajek\.dnx\bin;C:\Program Files (x86)\Microsoft VS Code\bin;C:\Users\hajek\AppData\Roaming\npm;C:\Program Files (x86)\IIS Express\PHP\v5.6\phpcs.bat
I have tried restarting my PC as well, but nothing has changed.
The call to phpcs
from Command Line is following:
C:\Users\hajek>phpcs --version
PHP_CodeSniffer version 2.6.0 (stable) by Squiz (http://www.squiz.net)
Running on Windows 10 Pro 1511.
Any idea what I could be doing wrong?
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Comments: 60 (6 by maintainers)
I have the same problem in linux, the message is:
phpcs: Unable to locate phpcs. Please add phpcs to your global path or use composer depency manager to install it in your project locally.
I am having the same issue. Mac OSX
workaround: copy your phpcs.bat to c:\windows
Just install with Homebrew. brew install php-code-sniffer
I confirm the issue on ubuntu 16.04 as well as the misspelled “depency”
Since this is closed and @hajekj seems to no longer experience issues I opened a new issue for Mac OS X user. https://github.com/ikappas/vscode-phpcs/issues/48
I installed it just now and received the following error when opening a PHP file.
Also please note that “depency” is misspelled. Should be “dependency.”
Yes, I confirm this issue.
In my case, it didn’t.
thanks @jonathanhuet - I did that and it’s a good temporary workaround. However I’d rather not have 2 installations of phpcs on my system if possible. I’ve been bitten by multiple installs of other tools in the past, so would like to avoid that rabbit hole 😃
A setting within the plugin to override/specify the phpcs path would be a reasonable solution, especially since there are already other settings that can be specified for the plugin.
Same issue here
Same issue, Windows 10. My path is C:\bin\phpcs\bin So no spaces.
I am having this issue in windows. Can anyone help me out? phpcs: Unable to locate phpcs. Please add phpcs to your global path or use composer depency manager to install it in your project locally.
@pjpmccarthy I installed PEAR and then Code Sniffer through PEAR and it was working out of box. No modifications necessary.
@hajekj Are you no longer experiencing the issue only because you had to copy something into your protected Windows directory? If so then the issue is not resolved, it has a work-around
“I assume that this issue has been resolved in 0.7.0 so closing” Why don’t you wait until you get confirmation from someone having the problem. For me it is NOT resolved. I have uninstalled phpcs plugin so that I don’t get the annoying error message anymore.
Sorry guys for the late response but I am swamped with work atm. If someone would like to contribute a fix it would be great!
@MadCoder253 this however isn’t very useful for those of us who cannot change their folder path.
@ikappas is there a fix for this around the corner? I’ve already uninstalled phpcs so I don’t get the error anymore but I would like to use phpcs when you have this fixed.