sublime-phpcs icon indicating copy to clipboard operation
sublime-phpcs copied to clipboard

Non-English Win7 ST3 Error

Open jl9404 opened this issue 9 years ago • 6 comments

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 avatar Dec 21 '15 14:12 jl9404

@jl9404 Can you create a pull request please?

benmatselby avatar Dec 21 '15 15:12 benmatselby

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

benmatselby avatar Jun 04 '16 13:06 benmatselby

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.

hellor0bot avatar Sep 27 '16 09:09 hellor0bot

+1 I have the same error

maxazan avatar Jan 23 '17 11:01 maxazan

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.

zsimple avatar Jan 23 '18 08:01 zsimple

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 ;-)

bs-thomas avatar Aug 27 '18 08:08 bs-thomas

Hey folks. It looks like @zsimple and @bs-thomas have provided the solutions here. Therefore I'm going to close this ticket down.

benmatselby avatar Oct 15 '23 15:10 benmatselby