sublime-phpcs
sublime-phpcs copied to clipboard
Non-English Win7 ST3 Error
Problem#1
If there are error(s) inside phpcs.bat or phpcfb.bat, the plugin will throw the following error:
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xa4 in position 5: invalid start byte
After I google the error message, I found that the below flag should be applied to the popen function.
universal_newlines=True
Problem#2
After I fixed the first bug, the plugin will throw the following error:
AttributeError: 'str' object has no attribute 'decode'
I made a quick fix to the program.
if st_version == 3 _and 'decode' in dir(data):
return data.decode()
else:
return data
Anyway, it is a good plugin! Thank you! And sorry for my bad English
@jl9404 Can you create a pull request please?
Reluctant to merge/make this change as I cannot test on windows, and no-one else seems to be impacted at the moment. Will review if someone with Windows wants to help
Having the same issue :(
File "phpcs in C:\Users\XXX\AppData\Roaming\Sublime Text 3\Installed Packages\Phpcs.sublime-package", line 179, in shell_out
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xad in position 14: invalid start byte
My config:
{
"phpcs_executable_path": "D:\\Dev\\phpcs\\scripts\\phpcs.bat",
"phpcs_php_path": "D:\\Dev\\php\\php.exe"
}
Running phpcs
from the command line is fine.
+1 I have the same error
I faced the same error but I found the answer finally. It is not a sublime-phpcs issue nor python problem in my case.
Just edit the "phpcs.bat", the last line, not "%PHPBIN%"
, only %PHPBIN%
, means remove the double quote around %PHPBIN%
.
Hope it can help someone.
For me, I'm facing a similar error on Japanese Windows 10 Pro. There is an issue with the algorithm. I did try to look, unfortunately I'm no Python guy.
Luckily though, startsWith("~") caught me while digging into the code, and it seems to run the logic a little different from the way it does when we specify "%PHPBIN%" or "%APPDATA%" or something of that sort.
So I tried to specify my path that starts with "~", and it worked!!
For me, I ended up doing: "php_cs_fixer_executable_path": "~/AppData/Roaming/Composer/vendor/bin/php-cs-fixer.bat",
Didn't really fix the problem, but successfully got away with it ;-)
Hey folks. It looks like @zsimple and @bs-thomas have provided the solutions here. Therefore I'm going to close this ticket down.