I can't seem to get the Yui Compressor plugin for Sublime Text 2 working, and keep getting the error like:

UnicodeDecodeError: 'ascii' codec can't decode byte 0x9e in position 19: ordinal not in range(128)
Writing file /C/Users/Nikola Brežnjak/Desktop/yuicompressor-2.4.7/build/justTesting.js with encoding UTF-8
Running java -jar C:\Users\Nikola Brežnjak\AppData\Roaming\Sublime Text 2\Packages\YUI Compressor\bin\yuicompressor-2.4.7.jar --charset utf-8 --preserve-semi --line-break 150 -o justTesting.min.js C:\Users\Nikola Brežnjak\Desktop\yuicompressor-2.4.7\build\justTesting.js
Traceback (most recent call last):
  File ".\sublime_plugin.py", line 337, in run_
  File ".\exec.py", line 154, in run
  File ".\exec.py", line 45, in __init__
UnicodeDecodeError: 'ascii' codec can't decode byte 0x9e in position 19: ordinal not in range(128)

I installed the plugin via package manager and I made sure I've put java in my PATH variable and if I run it via the console the YUI Compressor does its job.

有帮助吗?

解决方案

The issue was with the path in which my Sublime Text is installed - notice the ž character in my surname.

So, after a lot of searching I found out the solution here, and as stated there it seems to be the error within the exec.py file, which can be found in your Sublime Packages directory (for example: C:\Users\Nikola Brežnjak\AppData\Roaming\Sublime Text 2\Packages\Default). You have to change the line 45 from:

proc_env[k] = os.path.expandvars(v).encode(sys.getfilesystemencoding())

to:

proc_env[k] = os.path.expandvars(v.decode(sys.getfilesystemencoding())).encode(sys.getfilesystemencoding())

After this you have to save the file, and the plugin will reload automatically, and then the YUI compressor plugin will work flawlessly.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top