Closed jfelixetcetera closed 11 years ago
I also have this problem since the last update!
Apologies for the delay. I currently have no Internet connection at home. Have you see the last comment in the README file? Does that help in any way?
You mean the "Installed php-cs-fixer via Homebrew?" note? This isn't a problem with php-cs-fixer, but rather phpcs itself. (But do notice in my config fixer is pointed to the phar.)
So I'm not sure if there's a similar issue with phpcs, but since it's not packaged as a phar, it can't be exactly the same...
thx!
I had the same problem and to fix it I had to use the following config:
{
"phpcs_php_prefix_path": "/usr/local/bin/php",
"phpcs_executable_path": "/usr/local/opt/php-code-sniffer/scripts/phpcs",
"phpcs_additional_args": {
"--standard": "PSR2"
},
"phpcs_commands_to_php_prefix": ["Fixer"],
"phpmd_executable_path": "/usr/local/opt/php-md/libexec/phpmd.phar",
"php_cs_fixer_executable_path": "/usr/local/opt/php-cs-fixer/libexec/php-cs-fixer.phar"
}
Additionally, I had to set some execution permissions:
chmod +x /usr/local/opt/php-md/libexec/phpmd.phar
chmod +x /usr/local/opt/php-cs-fixer/libexec/php-cs-fixer.phar
Does this configuration fix it for everyone, can this issue be closed down?
I will try It today.
Van: Ben Selby notifications@github.com Beantwoorden - Aan: benmatselby/sublime-phpcs <reply+i-9158093-bc0b7183f848f833424a9414b409af908207d532-2812277@reply.gith ub.com> Datum: maandag 17 december 2012 09:44 Aan: benmatselby/sublime-phpcs sublime-phpcs@noreply.github.com CC: Alexander Janssen a.janssen@easy-cloud.eu Onderwerp: Re: [sublime-phpcs] Python Errno 8: CodeSniffer won't sniff (#57)
Does this configuration fix it for everyone, can this issue be closed down?
β Reply to this email directly or view it on GitHub https://github.com/benmatselby/sublime-phpcs/issues/57#issuecomment-11433970 .
Hi Alexander, any luck testing this? Am I OK to close this issue?
It fixed my issue with codesniffer, but phpcs gives an error:
Exception in thread Thread-72: Traceback (most recent call last): File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/thre ading.py", line 532, in *bootstrap_inner self.run() File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/thre ading.py", line 484, in run self.__target(_self.__args, _self.__kwargs) File "./phpcs.py", line 290, in run File "./phpcs.py", line 84, in get_errors File "./phpcs.py", line 244, in execute File "./phpcs.py", line 247, in parse_report File "./phpcs.py", line 92, in shell_out File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/subp rocess.py", line 623, in __init** errread, errwrite) File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/subp rocess.py", line 1141, in _execute_child raise child_exception OSError: [Errno 2] No such file or directory
Loading dictionary Packages/Language - English/en_US.dic Writing file /Users/AJanssen/Dropbox/DutchBridge/Taartenwinkel/api.taartenwinkel.nl/appli cation/controllers/documentstore.php with encoding UTF-8 [Phpcs] php -l -d display_errors=On /Users/AJanssen/Dropbox/DutchBridge/Taartenwinkel/api.taartenwinkel.nl/appli cation/controllers/documentstore.php Exception in thread Thread-76: Traceback (most recent call last): File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/thre ading.py", line 532, in *bootstrap_inner self.run() File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/thre ading.py", line 484, in run self.__target(_self.__args, _self.__kwargs) File "./phpcs.py", line 290, in run File "./phpcs.py", line 84, in get_errors File "./phpcs.py", line 244, in execute File "./phpcs.py", line 247, in parse_report File "./phpcs.py", line 92, in shell_out File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/subp rocess.py", line 623, in __init** errread, errwrite) File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/subp rocess.py", line 1141, in _execute_child raise child_exception OSError: [Errno 2] No such file or directory
All the paths are correct!
Van: Ben Selby notifications@github.com Beantwoorden - Aan: benmatselby/sublime-phpcs <reply+i-9158093-bc0b7183f848f833424a9414b409af908207d532-2812277@reply.gith ub.com> Datum: woensdag 19 december 2012 17:58 Aan: benmatselby/sublime-phpcs sublime-phpcs@noreply.github.com CC: Alexander Janssen a.janssen@easy-cloud.eu Onderwerp: Re: [sublime-phpcs] Python Errno 8: CodeSniffer won't sniff (#57)
Hi Alexander, any luck testing this? Am I OK to close this issue?
β Reply to this email directly or view it on GitHub https://github.com/benmatselby/sublime-phpcs/issues/57#issuecomment-11537952 .
That's a configuration issue too. Please see the first question in FAQs in the Readme. Let me know.
I was having problems with just PHP_CodeSniffer on its own. For me, the core fix is this as my settings:
{
"show_debug": true,
"phpcs_php_path": "/usr/local/bin/php",
"phpcs_executable_path": "/usr/local/opt/php-code-sniffer/scripts/phpcs",
"phpcs_additional_args": {
"--standard": "PSR2"
}
}
Specifically, the phpcs_executable_path
property. I was setting it to /usr/local/bin/phpcs
(which makes sense), but apparently it needs to be the value above. But using the settings above, the plugin works with CS. So this probably needs to go into the docs.
As for MD + Fixer, neither work for me. For MD, these settings:
{
"phpmd_run": true,
// @TODO chmod +x /usr/local/opt/php-md/libexec/phpmd.phar
"phpmd_executable_path": "/usr/local/opt/php-md/libexec/phpmd.phar"
}
cause this debug:
[Phpcs] /usr/local/opt/php-md/libexec/phpmd.phar /Users/joshua/Desktop/test.php text codesize,unusedcode,naming
Traceback (most recent call last):
File "./sublime_plugin.py", line 362, in run_
File "./phpcs.py", line 432, in run
File "./phpcs.py", line 287, in run
File "./phpcs.py", line 84, in get_errors
File "./phpcs.py", line 217, in execute
File "./phpcs.py", line 221, in parse_report
File "./phpcs.py", line 51, in debug_message
TypeError: argument 1 must be string without null bytes, not str
And with Fixer, adding these settings:
{
"phpcs_php_prefix_path": "/usr/local/bin/php",
"phpcs_commands_to_php_prefix": ["Fixer"],
"php_cs_fixer_show_quick_panel": true,
// @TODO chmod +x /usr/local/opt/php-cs-fixer/libexec/php-cs-fixer.phar
"php_cs_fixer_executable_path": "/usr/local/opt/php-cs-fixer/libexec/php-cs-fixer.phar"
}
cause this debug output:
[Phpcs] /usr/local/opt/php-cs-fixer/libexec/php-cs-fixer.phar fix /Users/joshua/Desktop/test.php --verbose --level=all
[Phpcs] ?r????
So no idea there. But CS was the main thing I needed working, so I'm where I want be.
The issue with the ?r????
garbage output is due to the detect_unicode
setting in PHP.
This is the content of the bin/php-cs-fixer
that would normally run to start up php-cs-fixer.phar
:
/usr/bin/env php -d allow_url_fopen=On -d detect_unicode=Off /usr/local/Cellar/php-cs-fixer/0.1.0/libexec/php-cs-fixer.phar $*
The magic happens with the detect_unicode=Off
setting, which does not exist in the default PHP configuration when installed via Homebrew (and possibly the default OS X PHP as well). I had to append detect_unicode=Off
to the end of my /usr/local/etc/php/5.3/php.ini
file (php53 from Homebrew) and everything works fine.
I also did not have the need to use phpcs_commands_to_php_prefix
in the sublime-phpcs settings. This is what did it for me (everything installed via Homebrew):
{
"phpcs_executable_path": "/usr/local/opt/php-code-sniffer/scripts/phpcs",
"phpmd_executable_path": "/usr/local/opt/php-md/libexec/phpmd.phar",
"php_cs_fixer_executable_path": "/usr/local/opt/php-cs-fixer/libexec/php-cs-fixer.phar"
}
Of course, I had to run the following commands as suggested previously:
chmod +x /usr/local/opt/php-md/libexec/phpmd.phar
chmod +x /usr/local/opt/php-cs-fixer/libexec/php-cs-fixer.phar
Excellent explanation @salaman
Does this resolve everyones issues related to this ticket? If so I am going to close it over the next couple of days if no reply.
Closing ticket as per above
Just wanted to add a note here - I experienced all of this as well tonight. My phar's are executable - so I'm not having to chmod them - but for some reason the Python script will not follow a symlink. Have to configure each of these tools down to the real-world file.
I've just installed sublime-phpcs (via Package Control), and am having some issues getting it running. I installed CS via homebrew (as well as Fixer and MD, but those are disabled for now). I have no problems running CS from the command line (it returns 14 errors), but get the following via ST2:
Here is my config:
Uncommenting the "phpcs_php_prefix_path" and "phpcs_commands_to_php_prefix" lines allows it to run, but returns this:
Any thoughts?