Closed TNAJanssen closed 11 years ago
Hi there..
Which version of php-cs-fixer are you using? I've got the latest version and a fresh install of this plugin and when looking in the console I can see:
[Phpcs] /usr/local/bin/php-cs-fixer.phar fix /Users/bselby/path/to/file.php --verbose --level=all
I'm using version 0.2, it did work before! it suddenly stopped working. This is what in my console:
php-cs-fixer fix /Users/AJanssen/Dropbox/Easy Cloud/Projecten/Zend Modules/ACL/src/Service/Permission.php --verbose --level=all
When i run this manual it says
[RuntimeException]
Too many arguments.
When i escape the spaces like this: php-cs-fixer fix /Users/AJanssen/Dropbox/Easy\ Cloud/Projecten/Zend\ Modules/ACL/src/Service/Permission.php --verbose --level=all it works!
i do have an error under that command:
[Phpcs] ERROR: option "- " not known.
Usage: phpcs [-nwlsaepvi] [-d key[=value]]
[--report=
So is the bug here that you have spaces in the paths and the plugin cannot handle that?
It seems like it, when i try it in terminal it works perfectly! the phpcs on the other hand does work! although the error from above! Here is the complete console output when i try to save:
[Phpcs] /Applications/MAMP/bin/php/php5.4.4/bin/phpcs -l -d display_errors=On /Users/AJanssen/Dropbox/Easy Cloud/Projecten/Zend Modules/ACL/src/Service/Permission.php [Phpcs] php-cs-fixer fix /Users/AJanssen/Dropbox/Easy Cloud/Projecten/Zend Modules/ACL/src/Service/Permission.php --verbose --level=all [Phpcs] [Phpcs] ERROR: option "- " not known.
Usage: phpcs [-nwlsaepvi] [-d key[=value]]
[--report=
OK two things.
I assume there are errors that php-cs-fixer would find in your file, and secondly, I think the error seems to be in phpcs. Can you paste your configuration file for me please
Here is my configuration:
{ // 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"],
// 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
// - 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": [],
// 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": "/Applications/MAMP/bin/php/php5.4.4/bin/phpcs",
// Additional arguments you can specify into the application
//
// Example:
// {
// "--standard": "PEAR",
// "-n"
// }
"phpcs_additional_args": {
"--standard": "PEAR",
"--warning-severity": "0"
},
// PHP-CS-Fixer settings
// Fix the issues on save
"php_cs_fixer_on_save": true,
// 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": "/usr/local/bin/php-cs-fixer",
// Additional arguments you can specify into the application
//
// Example:
// {
// "--level": "all"
// }
"php_cs_fixer_additional_args": {
"--level": "all"
},
// PHP Linter settings
// Are we going to run php -l over the file?
"phpcs_linter_run": true,
// 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": "/Applications/MAMP/bin/php/php5.4.4/bin/phpcs",
// 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": ""
}
}
OK, this is rather strange.. I cannot replicate this, which is a concern.. Could you close ST2 down and re-open it (I know, very lame of me to ask)
Already did:P after each change in the config. hmm just tested a file which hasn't spaces in the directory! i will reinstall php-cs-fixer and come back with the results!
Didn't work! it looks like the command doesn't run!
Is there a way to get the output of the command so i can check what goes wrong?
Output? Unsure what you mean.. If you open up the console "View" > "Show Console", and make sure the "show_debug" setting is true, which it seems to be, that gives you all the debug information
I mean the output of php-cs-fixer, because only thing i see in console is: [Phpcs] /usr/local/bin/php-cs-fixer fix /Users/AJanssen/Dropbox/Easy Cloud/Projecten/Zend Modules/ACL/src/Service/Permission.php --verbose --level=all [Phpcs]
i can't see what php-cs-fixer gives back. I already reinstalled php-cs-fixer, phpcs and sublime-phpcs! I really don't want to reinstall sublime text:(
With that output, to me, that suggests that php-cs-fixer has not found anything to fix anymore. I get the same for files that have either a) been fixed or b) has nothing to fix inside it
That is weird! when i run it from terminal it says: MacBook-Pro-van-Alexander-Janssen:Site AJanssen$ php-cs-fixer fix /Users/AJanssen/Dropbox/Easy\ Cloud/Projecten/Zend\ Modules/ACL/src/Service/Permission.php --verbose --level=all 1) /Users/AJanssen/Dropbox/Easy Cloud/Projecten/Zend Modules/ACL/src/Service/Permission.php (controls_spaces)
Do you then do a revert on that file before trying in ST2? Either by git/svn/hg etc?
Yes i do a revert(dropbox), i also tried ST2 first then terminal!
I'll need to do further investigation on this when I'm not at work I'm afraid. Initial checks have left me unable to replicate this bug, which is worrying.
I'm will reinstall my sublime text 2 saturday, i hope that helps. If you want me to run commands or other things just ask.
This is what I'm currently seeing in my ST console log:
[Phpcs] /usr/local/bin/php-cs-fixer fix /Users/jhoffmann/sugar/internal/custom/si_logic_hooks/LeadHooks.php --verbose --fixers=indentation,linefeed,trailing_spaces,unused_use,php_closing_tag,short_tag,return,braces,phpdoc_params,eof_ending,extra_empty_lines,controls_spaces,elseif
Traceback (most recent call last):
File "./sublime_plugin.py", line 362, in run_
File "./phpcs.py", line 486, in run
File "./phpcs.py", line 356, in fix_standards_errors
File "./phpcs.py", line 84, in get_errors
File "./phpcs.py", line 175, in execute
File "./phpcs.py", line 178, in parse_report
File "./phpcs.py", line 92, in shell_out
File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/subprocess.py", line 623, in __init__
errread, errwrite)
File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/subprocess.py", line 1141, in _execute_child
raise child_exception
OSError: [Errno 8] Exec format error
The command it's running works fine if I copy it into a Terminal.
This is on OS X 10.7, with the following user config:
{
"show_debug": true,
"phpcs_additional_args": {
"--standard": "/Users/jhoffmann/sugar/internal/custom/iapps_configs/phpcs/ruleset.xml",
"-n": ""
},
"php_cs_fixer_on_save": true,
"php_cs_fixer_show_quick_panel": true,
"php_cs_fixer_executable_path": "/usr/local/bin/php-cs-fixer",
"php_cs_fixer_additional_args": {
"--fixers": "indentation,linefeed,trailing_spaces,unused_use,php_closing_tag,short_tag,return,braces,phpdoc_params,eof_ending,extra_empty_lines,controls_spaces,elseif"
}
}
Ok, figured out my problem, not sure if it will help others. I used Homebrew to install php-cs-fixer and the file it puts in /usr/local/bin is actually a symlink to a symlink to a wrapper around the actual binary.
/usr/local/bin/php-cs-fixer ->
/usr/local/Cellar/php-cs-fixer/0.1.0/bin/php-cs-fixer ->
/usr/local/Cellar/php-cs-fixer/0.1.0/libexec/php-cs-fixer.phar
Setting php_cs_fixer_executable_path to the .phar in the plugin settings fixes it, apparently Python's subprocess doesn't like symlinks of symlinks of wrappers.
Thanks for the update John. I was baffled by this issue to be honest. Closing it down, as it doesn't sound like something that can be fixed in the plugin.
Updated the README to document the above
Nevermind just found it! It says i'm using to much arguments(didn't change anything about it!)
The problem is spaces in directory or file name! can you fix this in python?