vscode-phpcs: phpcs: Unable to locate phpcs, Please add phpcs to global path

From @ritayzy on July 8, 2016 6:50

  • VSCode Version: 1.3.0 (1.3.0)
  • OS Version: 10.11.3 (15D21)
  • vs plugin: phpcs

Steps to Reproduce:

when i open a .php file, the tips show that:

image

in my termianl, i input this which phpcs, show that:

image

Someone can help me. Thanks!

Copied from original issue: Microsoft/vscode#8900

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 23 (1 by maintainers)

Most upvoted comments

This one worked for me:

https://stackoverflow.com/questions/47174009/visual-code-studio-unable-to-locate-phpcs

1- Go to extensions and install the plugin…“phpcs”. 2- Search for the extension if you had install it. 3- Disable the extension.

Closing as duplicate of Microsoft/vscode#8434

Hi guys if someone still needs help about this “Unable to locate phpcs …” error message try this: you just need to install phpcs globally via Composer. 1- Install Composer from https://getcomposer.org/download/ if you don’t have it, 2- After Composer is installed, open a command prompt wherever you want and run this command =>

composer global require squizlabs/php_codesniffer

In your VS Code “User Settings” (“Preferences”), add:

    "phpcs.executablePath":"/path/to/phpcs"

See item 4, above, from the maintainer: https://github.com/ikappas/vscode-phpcs/issues/14#issuecomment-367287572

I have the same issue. Why is this closed?

Why is this closed? There is no fix for this yet. I have the same issue but it works when I start vscode from the command line.

Try to follow this steps:

  • Installing globally PHPCS
composer global require squizlabs/php_codesniffer
  • Know yout $path
echo $path
  • Add line below into your ~/.zshrc ou ~/.bashrc
export PATH="/home/$USER/.config/composer/vendor/bin:$PATH"

Im facing this problem too, Would you mark this as open issue again @joaomoreno ?

This is still an un-resolved issue.

@joaomoreno This is not a dupe of Microsoft/vscode#8434 Nothing in that thread fixes this issue. I am seeing the exact same problem with 1.19.1 on OSX. Is there a known fix or workaround?

I just released vscode-phpcs 1.0.0 which supports the VSCode 1.20+ and includes many enhancements most notable of which are:

  1. multi root support
  2. lint as you type support
  3. automatic configuration search support
  4. ability to set phpcs.executablePath
  5. ability to set phpcs.showWarnings
  6. ability to set phpcs.showSources
  7. ability to set phpcs.composerJsonPath to something other that workspaceRoot/composer.json
  8. ability to enable phpcs.trace.server with messages or verbose option for tracing errors.

I would like to give my thanks to all the people that helped track down issues in the previous betas and hope the new features help you get things done easier. On that note, I am closing this issue to properly track any new issues in the new release. If you find this issue persists or any other issue please feel free to open a new ticket for v.1.0.0.

On Ubuntu 17.10 sudo apt install php-codesniffer resolved the issue for me.

i installed phpcs global via composer , but error persists i had to insert executable phat manually. i’m using ubuntu 16.10

in user workspace setting(not user setting) "phpcs.executablePath": "/Users/egirlasm/.composer/vendor/bin/phpcs" finally must be add phpcs in the end

I’m having the issue on macOS High Sierra.

Installed all according to instruction:

  1. Installed composer globally (Composer version 1.6.3).
  2. composer global require squizlabs/php_codesniffer.
  3. Installed phpcs VSC extension.