benmatselby / sublime-phpcs

🔍 PHP CodeSniffer, PHP Coding Standard Fixer, Linter, and Mess Detector Support for Sublime Text
Other
812 stars 126 forks source link

FileNotFoundError: [Errno 2] No such file or directory #198

Closed celsoendo closed 4 years ago

celsoendo commented 4 years ago

OS: Linux Pop OS 20.04 Sublime 3.2.2 Build 3211 Phpcs v2020.01.17.08.29.37

Phpcs and PHP locations:

$ which phpcs
/usr/bin/phpcs

$ which php
/usr/bin/php

Phpcs config file:

{
    // Plugin settings

    // Turn the debug output on/off
    "show_debug": true,

    // Which file types (file extensions), do you want the plugin to
    // execute for
    "extensions_to_execute": ["php"],

    // Do we need to blacklist any sub extensions from extensions_to_execute
    // An example would be ["twig.php"]
    "extensions_to_blacklist": [],

    // Execute the sniffer on file save
    "phpcs_execute_on_save": true,

    // Show the error list after save.
    "phpcs_show_errors_on_save": false,

    // Show the errors in the gutter
    "phpcs_show_gutter_marks": true,

    // Show outline for errors
    "phpcs_outline_for_errors": true,

    // Show the errors in the status bar
    "phpcs_show_errors_in_status": true,

    // Show the errors in the quick panel so you can then goto line
    "phpcs_show_quick_panel": true,

    // The path to the php executable.
    // Needed for windows, or anyone who doesn't/can't make phars
    // executable. Avoid setting this if at all possible
    "phpcs_php_prefix_path": "",

    // Options include:
    // - Sniffer
    // - Fixer
    // - MessDetector
    // - CodeBeautifier
    //
    // This will prepend the application with the path to php
    // Needed for windows, or anyone who doesn't/can't make phars
    // executable. Avoid setting this if at all possible
    "phpcs_commands_to_php_prefix": [],

    // What color to stylise the icon
    // https://www.sublimetext.com/docs/3/api_reference.html#sublime.View
    // add_regions
    "phpcs_icon_scope_color": "comment",

    // PHP_CodeSniffer settings

    // Do you want to run the phpcs checker?
    "phpcs_sniffer_run": true,

    // Execute the sniffer on file save
    "phpcs_command_on_save": true,

    // It seems python/sublime cannot always find the phpcs application
    // If empty, then use PATH version of phpcs, else use the set value
    "phpcs_executable_path": "/usr/bin/phpcs",

    // Additional arguments you can specify into the application
    //
    // Example:
    // {
    //     "--standard": "PEAR",
    //     "-n"
    // }
    "phpcs_additional_args": {
        "--standard": "PSR2",
        "-n": ""
    },

    // PHP-CS-Fixer settings

    // Fix the issues on save
    "php_cs_fixer_on_save": false,

    // Show the quick panel
    "php_cs_fixer_show_quick_panel": false,

    // Path to where you have the php-cs-fixer installed
    "php_cs_fixer_executable_path": "",

    // Additional arguments you can specify into the application
    "php_cs_fixer_additional_args": {

    },

    // phpcbf settings

    // Fix the issues on save
    "phpcbf_on_save": false,

    // Show the quick panel
    "phpcbf_show_quick_panel": false,

    // Path to where you have the phpcbf installed
    "phpcbf_executable_path": "",

    // Additional arguments you can specify into the application
    //
    // Example:
    // {
    //     "--level": "all"
    // }
    "phpcbf_additional_args": {
        "--standard": "PSR2"
    },

    // PHP Linter settings

    // Are we going to run php -l over the file?
    "phpcs_linter_run": false,

    // Execute the linter on file save
    "phpcs_linter_command_on_save": true,

    // It seems python/sublime cannot always find the php application
    // If empty, then use PATH version of php, else use the set value
    "phpcs_php_path": "/usr/bin/php",

    // What is the regex for the linter? Has to provide a named match for 'message' and 'line'
    "phpcs_linter_regex": "(?P<message>.*) on line (?P<line>\\d+)",

    // PHP Mess Detector settings

    // Execute phpmd
    "phpmd_run": false,

    // Execute the phpmd on file save
    "phpmd_command_on_save": true,

    // It seems python/sublime cannot always find the phpmd application
    // If empty, then use PATH version of phpmd, else use the set value
    "phpmd_executable_path": "",

    // Additional arguments you can specify into the application
    //
    // Example:
    // {
    //     "codesize,unusedcode"
    // }
    "phpmd_additional_args": {
        "codesize,unusedcode,naming": ""
    },

    // PHP Scheck settings

    // Execute scheck
    "scheck_run": false,

    // Execute the scheck on file save
    "scheck_command_on_save": false,

    // It seems python/sublime cannot always find the scheck application
    // If empty, then use PATH version of scheck, else use the set value
    "scheck_executable_path": "",

    // Additional arguments you can specify into the application
    //
    //Example:
    //{
    //  "-php_stdlib" : "/path/to/pfff",
    //  "-strict" : ""
    //}
    "scheck_additional_args": {
        "-strict" : ""
    }
}

Error when saving a file:

FileNotFoundError: [Errno 2] No such file or directory: '/usr/bin/phpcs'

If I run the command manually on terminal, it works:

$ /usr/bin/phpcs --report=checkstyle --standard=PSR2 -n /home/cendo/Downloads/info.php
<?xml version="1.0" encoding="UTF-8"?>
<checkstyle version="3.5.6">
</checkstyle>

Tried changing the configuration file like this:

"phpcs_php_prefix_path": "/usr/bin/php",
"phpcs_commands_to_php_prefix": ["Sniffer"],

And the error is:

FileNotFoundError: [Errno 2] No such file or directory: '/usr/bin/php'

If I run the command manually on terminal, it works:

$ /usr/bin/php /usr/bin/phpcs --report=checkstyle --standard=PSR2 -n /home/cendo/Downloads/info.php
<?xml version="1.0" encoding="UTF-8"?>
<checkstyle version="3.5.6">
</checkstyle>

Any ideas?! Thx!

celsoendo commented 4 years ago

The issue was because Sublime was installed using Pop Shop (Pop Os's app store). I uninstalled Sublime and installed Sublime using Sublime's own repo from their website and now it's working. So there's definitely some bug on Pop Os app store. I'm reporting to them.