SublimeLinter-phpcs icon indicating copy to clipboard operation
SublimeLinter-phpcs copied to clipboard

WARNING: phpcs cannot locate 'phpcs'

Open rollecode opened this issue 8 years ago • 16 comments

My Sublime Text is not linting at the moment for some reason.

SublimeLinter: #4 linter.py:738: 'phpcs' is linting 'pricing.php'
SublimeLinter: #4 composer_linter.py:58: WARNING: phpcs cannot locate 'phpcs'
SublimeLinter: sublime_linter.py:287: Linting buffer 59 took 0.03s

Command line:

➜  ~ phpcs --version
PHP_CodeSniffer version 2.9.2 (stable) by Squiz (http://www.squiz.net)
➜  ~ which phpcs
/Users/rolle/Projects/phpcs/scripts/phpcs

SublimeLinter.sublime-settings

  {
    // Set to true to print extra information in the console.
    "debug": true,

    // When in the "background" lint mode, this value determines
    // a delay before a request is send to the linter
    "delay": 0.25,

    // Available gutter themes:
    // Blueberry Cross
    // Blueberry Round
    // Circle
    // Danish Royalty
    // Default
    // Hands
    // Knob
    // Knob Symbol
    // Koloria
    // ProjectIcons
    // Note that you may need to change the "icon" property in "styles"
    // to an icon in the theme (they usually include "warning" and "error")
    "gutter_theme": "Default",

    // Lint Modes determine when the linter is run
    // background: asynchronously on every change
    // load_save: when a file is opened and every time it's saved
    // manual: only when calling the Lint This View command
    "lint_mode": "background",    
    "linters":
    {
      "csslint":
      {
        "disable": false,
        "args":
        [
        ],
        "errors": "",
        "excludes":
        [
        ],
        "ignore": "",
        "warnings": ""
      },
      "phpcs":
      {
        "disable": false,
        "standard": "${folder}/content/themes/${project_base_name}/phpcs.xml",
        "args":
        [
        ],
        "cmd": "/Users/rolle/Projects/phpcs/scripts/phpcs",
        "excludes":
        [
        ],
        "paths":
        {
          "linux":
          [
            "/Users/rolle/Projects/phpcs/scripts/",
            "/Users/rolle/Projects/phpcs/bin/",
            "/usr/local/bin/"
          ],
          "osx":
          [
            "/Users/rolle/Projects/phpcs/scripts/",
            "/Users/rolle/Projects/phpcs/bin/",
            "/usr/local/bin/"
          ],
          "windows":
          [
          ]
        },
      },
      "sass":
      {
        "disable": true,
        "args":
        [
        ],
        "excludes":
        [
        ]
      },
      "scss":
      {
        "disable": false,
        "args":
        [
        ],
        "exclude-linter": "",
        "excludes":
        [
        ],
        "include-linter": ""
      },
      "sublimesyntax":
      {
        "disable": false,
        "args":
        [
        ],
        "excludes":
        [
        ]
      }
    },
    "no_column_highlights_line": false,
    "paths":
    {
      "linux":
      [
      ],
      "osx":
      [
        "/usr/local/bin/"
      ],      "windows":
      [
      ]
    },
    "show_marks_in_minimap": true,
    "syntax_map":
    {
      "html (django)": "html",
      "html (rails)": "html",
      "html 5": "html",
      "php": "html",
      "python django": "python"
    },
  }

rollecode avatar May 30 '18 10:05 rollecode

Hi!

      "phpcs":
      {
        "disable": false,
        "standard": "${folder}/content/themes/${project_base_name}/phpcs.xml",
        "args":
        [
        ],
        "cmd": "/Users/rolle/Projects/phpcs/scripts/phpcs",
        "excludes":
        [
        ],
        "paths":
        {
          "linux":
          [
            "/Users/rolle/Projects/phpcs/scripts/",
            "/Users/rolle/Projects/phpcs/bin/",
            "/usr/local/bin/"
          ],
          "osx":
          [
            "/Users/rolle/Projects/phpcs/scripts/",
            "/Users/rolle/Projects/phpcs/bin/",
            "/usr/local/bin/"
          ],
          "windows":
          [
          ]
        },
      },

Neither cmd nor paths are 'valid' (evaluated) settings. cmd should be executable. If you really have to mangle PATH, you can use "env": {"PATH": "..."}

kaste avatar May 30 '18 10:05 kaste

Thanks! removing cmd and paths, added executable. That solved it.

rollecode avatar May 30 '18 11:05 rollecode

i'm having a similar problem. i can't seem to get it working.

{
    "folders":
    [
        {
            "path": "."
        }
    ],
    "settings": {
        "debug": true,

        ...

        "SublimeLinter.linters.phpcs.disable": false,
        "SublimeLinter.linters.phpcs.standard": "${folder}/phpcs.xml",
        "SublimeLinter.linters.phpcs.executable": "/Users/user/.composer/vendor/bin/phpcs",
        "SublimeLinter.linters.phpcs.env": {
            "PATH": "/Users/user/.composer/vendor/bin"
        },
        "SublimeLinter.linters.phpcs.paths": {
            "osx": ["/Users/user/.composer/vendor/bin"]
        },

        ...

    }
}

rizkysyazuli avatar Jul 10 '18 10:07 rizkysyazuli

@rizkysyazuli What you posted are actually project settings. But 'debug' and '*.paths' are not supported here.

Please enable debug mode in the global SublimeLinter settings. What error message do you get there?

kaste avatar Jul 10 '18 13:07 kaste

@kaste ah, okay. the docs is a bit unclear about where to put it. but thx, it works now.

rizkysyazuli avatar Jul 19 '18 08:07 rizkysyazuli

hello @kaste this is the closest issue i got related to my problem and wasn't sure if i shud create a new issue but hopefully you can help me resolve it.

Error Log in sublime console:

SublimeLinter: #6 composer_linter.py:60 WARNING: phpcs cannot locate 'phpcs'
Please refer to the readme of this plugin and our troubleshooting guide: http://www.sublimelinter.com/en/stable/troubleshooting.html

image

// SublimeLinter Settings - User
{
    "debug": true,
    "linters": {
        "eslint": {
            "env": {"PATH":"/usr/local/bin/"}
        },
        "phpcs":
        {
            "disable": false,
            "standard": "${folder}/content/themes/${project_base_name}/phpcs.xml",
            "args":
            [
            ],
            "cmd": "/home/piru/.config/composer/vendor/bin/phpcs",
            "excludes":
            [
            ],
            "paths":
            {
                "linux":
                [
                    "/home/piru/.config/composer/vendor/bin/phpcs",
                    "/home/piru/.config/composer/vendor/bin",
                    "/usr/local/bin/"
                ],
                "osx":
                [
                ],
                "windows":
                [
                ]
            }
        }
    }
}

Am sure am doing something wrong but just can't aint seeing it yet :thinking:

Also i installed squizlabs/PHP_CodeSniffer via composer

pirupius avatar Nov 15 '18 13:11 pirupius

cmd and paths is not supported there. Remove paths setting and rename cmd to executable.

kaste avatar Nov 15 '18 13:11 kaste

That did the trick thank you :bowing_man: @kaste

pirupius avatar Nov 15 '18 14:11 pirupius

Hi there! So sorry to tack onto this closed issue but I have something similar going on. I get the following error in my Sublime console SublimeLinter: #1 composer_linter.py:60 WARNING: phpcs cannot locate 'phpcs'

To install the PHP CodeSniffer, I downloaded the Phar files for each command and created alias for them in my bashrc file.

Here are my user settings:

// SublimeLinter Settings - User
{
    "debug": true,
    "gutter_theme": "Default",
    "linters": {
        "phpcs": {
            "disable": false,
            "excludes": [],
            "args": "--standard=WordPress",
        },
    },
    "styles": [
        {
            "mark_style": "fill",
            "priority": 1,
            "scope": "region.yellowish markup.changed.sublime_linter markup.warning.sublime_linter",
            "icon": "star",
            "types": [
                "warning"
            ]
        },
        {
            "mark_style": "fill",
            "priority": 1,
            "scope": "region.purpleish markup.deleted.sublime_linter markup.error.sublime_linter",
            "icon": "star",
            "types": [
                "error"
            ]
        }
    ],
}

metalandcoffee avatar Jan 01 '19 16:01 metalandcoffee

Hi @metalandcoffee!

bash aliases are not automatically discoverable. Ideally you create a symlink in one of the paths already in $PATH which points to the real executable.

kaste avatar Jan 01 '19 18:01 kaste

Creating a symbolic link resolved my issue! Thank you @kaste

metalandcoffee avatar Jan 01 '19 18:01 metalandcoffee

@kaste I need some help

phpcs version

PHP_CodeSniffer version 3.4.2 (stable) by Squiz (http://www.squiz.net)

which phpcs

/Users/piru/.composer/vendor/bin/phpcs

Error

SublimeLinter: WARNING: phpcs cannot locate 'phpcs'
Please refer to the readme of this plugin and our troubleshooting guide:http://www.sublimelinter.com/en/stable/troubleshooting.html

Then i added this setup

"linters": {
    "phpcs": {
        "disable": false,
        "standard": "${folder}/content/themes/${project_base_name}/phpcs.xml",
        "cmd": "/Users/piru/.composer/vendor/bin/phpcs",
        "paths":
        {
	    "osx":
            [
	            "/Users/piru/.composer/vendor/bin/phpcs/scripts/",
	            "/Users/piru/.composer/vendor/bin/phpcs/bin/",
	            "/usr/local/bin/"
            ],
        }
    },
}

When the error persisted i got rid of the paths and changed cmd to executable

"linters": {
    "phpcs": {
        "disable": false,
        "standard": "${folder}/content/themes/${project_base_name}/phpcs.xml",
        "executable": "/Users/piru/.composer/vendor/bin/phpcs",
    },
}

But still the error persisted.

pirupius avatar Sep 13 '19 10:09 pirupius

Should be a different error message at least 🤔

kaste avatar Sep 13 '19 10:09 kaste

This is what i get after restarting sublime

plugins loaded
SublimeLinter: WARNING: phpcs cannot locate 'phpcs'
Please refer to the readme of this plugin and our troubleshooting guide: http://www.sublimelinter.com/en/stable/troubleshooting.html
Emmet: No need to update PyV8
Package Control: No updated packages

pirupius avatar Sep 13 '19 10:09 pirupius

Hm. Looks like it doesn't pick your settings. Which file you added those?

kaste avatar Sep 13 '19 10:09 kaste

@kaste That was the issue 🤦‍♂ The settings i added were in the wrong location. I had added them to generic sublime settings instead of the linter settings. Thanx a bunch.

pirupius avatar Sep 13 '19 11:09 pirupius