benmatselby / sublime-phpcs

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

WindowsError: [Error 193] %1 is not a valid Win32 application #107

Closed Trudko closed 10 years ago

Trudko commented 10 years ago

Hi,

I tried plugin with ST2 and ST3 on Windows 7(64bit) pro and on both of those I got error when trying to use PHP Code Sniffer.

It worked alright when I have used from command line

Here are my settings.

{ "show_debug": true, "extensions_to_execute": ["php"], "extensions_to_blacklist": [], "phpcs_execute_on_save": true, "phpcs_show_errors_on_save": true, "phpcs_show_gutter_marks": true, "phpcs_outline_for_errors": false, "phpcs_show_errors_in_status": true, "phpcs_show_quick_panel": false, "phpcs_php_prefix_path": "C:\dev\tools\wamp\bin\php\php5.3.13\php.exe", "phpcs_commands_to_php_prefix": [], "phpcs_sniffer_run": true, "phpcs_command_on_save": true, "phpcs_executable_path": "C:\dev\tools\wamp\bin\php\php5.3.13\phpcs.bat", "phpcs_additional_args": { "--standard": "PEAR", "-n": "" }, "php_cs_fixer_on_save": true, "php_cs_fixer_show_quick_panel": true, "php_cs_fixer_executable_path": "C:\dev\tools\php\php-cs-fixer.phar", "php_cs_fixer_additional_args": { "--level": "all" }, "phpcs_linter_run": true, "phpcs_linter_command_on_save": true, "phpcs_php_path": "C:\dev\tools\wamp\bin\php\php5.3.13\php.exe", "phpcs_linter_regex": "(?P.*) on line (?P\d+)" }

benmatselby commented 10 years ago

I think it is because you need to double \ your path, please see the examples here: https://github.com/benmatselby/sublime-phpcs/blob/master/example-settings/windows-7-phpcs-fixer-linter.example

Trudko commented 10 years ago

Hi,

thank you for quick answer. Actually github stripped one of backslash I do have double \ in my paths.

benmatselby commented 10 years ago

I'm afraid I have no access to a windows machine anymore, so resorting to googling:

http://support.microsoft.com/kb/812486

Also, not sure you need to define: phpcs_php_prefix_path. This is needed on windows for phars:

http://www.soulbroken.co.uk/code/sublimephpcs/

Is the linting part working?

benmatselby commented 10 years ago

Closing the issue, as no further comments in 2 months, and I would need more information to help reproduce and fix this

kazitanvirahsan commented 10 years ago

I have also got the same issue : WindowsError: [Error 193] %1 is not a valid Win32 application

Trudko commented 10 years ago

I was able to resolve it by using proper configuration from tutorial.

kazitanvirahsan commented 10 years ago

Thanks @Trudko for the clue. I had changed "phpcs_commands_to_php_prefix": "['Linter']" to "phpcs_commands_to_php_prefix": "['Fixer']" to resolve the issue. Happy cs.

rogatec commented 9 years ago

Thanks @kazitanvirahsan !

In the default settings file there is no hint to this setting "Fixer". This solved my problem that php-cs-fixer didn't work.

In case anyone needs some hints, here are my current user settings:

{
    // Turn the debug output on/off
    "show_debug": false,

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

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

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

    // 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,

    // php paths
    "phpcs_php_path": "C:\\php\\php.exe",
    "phpcs_php_prefix_path": "C:\\php\\php.exe",

    // PHP_CodeSniffer settings
    "phpcs_additional_args": {
        "--standard": "PSR2",
        "-n": ""
    },

    "phpcs_commands_to_php_prefix": ["Fixer"],

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

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

    "phpcs_executable_path": "C:\\php\\phpcs.bat",

    // 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": true,

    // Path to where you have the php-cs-fixer installed
    "php_cs_fixer_executable_path": "C:\\php\\php-cs-fixer.phar"
}
benmatselby commented 9 years ago

Hi @rogatec

Could you explain this a little more please:

In the default settings file there is no hint to this setting "Fixer".

I've just checked and the default settings say:

    // Options include:
    // - Sniffer
    // - Fixer
    // - Mess Detector
    //
    // 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

Let me know how I can improve this so it is clearer for others.

rogatec commented 9 years ago

Hi @benmatselby

Thank you for the response, really appreciated!

I'm not so familiar with php-cs-fixer and CodeSniffer. Therefore a little example would be nice, if you can include this in your default file or after the installation. Something like "how to setup the psr2 standard but exclude psr0."

Perhaps I just have to read the manual of the pear packages to understand it better how to set everything up.

On other forums some people accidently writing their Windows paths without escaping backslashes. So if you may include a hint in your comment of the default settings file?

Background: I thought, when setting up php_cs_fixer_additional_args it would work, but I got an error in the console , so I included "phpcs_commands_to_php_prefix": ["Fixer"] and then everytihng worked.

PS: I just saw your configuration page <- there is a clear hint to the "fixers" option. I just looked in the settings file - unfortunately...

evrend commented 8 years ago

Thank you so much @kazitanvirahsan! My settings working with windows 10.

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

    // Do not execute for twig files
    "extensions_to_blacklist": ["blade.php"],

    // 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": "C:\\PHP\\php.exe",

    // 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": "C:\\PHP\\phpcs.bat",

    // Path to where you have the php-cs-fixer installed
    "php_cs_fixer_executable_path": "C:\\PHP\\php-cs-fixer.phar",

    // Options include:
    // - Sniffer
    // - Fixer
    // - Mess Detector
    //
    // 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": ["Fixer"],

    // Fix the issues on save
    "php_cs_fixer_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": "C:\\PHP\\php.exe",

    // Path to where you have the phpcbf installed
    "phpcbf_executable_path": "C:\\PHP\\phpcbf.bat",

    // 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": "C:\\PHP\\phpmd.phar",

 }