nicosantangelo / sublime-gulp

Run Gulp tasks and use snippets from Sublime Text
https://sublime-gulp.nicosantangelo.com/
MIT License
155 stars 18 forks source link

Gulp: 'ascii' codec can't encode characters #29

Closed design-gur closed 9 years ago

design-gur commented 9 years ago

Win 8.1 | Sublime Text 2 | Gulp

Gulp: 'ascii' codec can't encode characters in position 46-50: ordinal not in range(128)

Any ideas?

nicosantangelo commented 9 years ago

Hmm that's weird, can you tell me which task are you running and (if you can) the output on the console?

design-gur commented 9 years ago

Just trying to start main one.

Gulp

About the output, it says the same as on the first screenshot, when I'm trying to run Gulp. But, some other ST plugins (which works fine), outputs this:

Traceback (most recent call last): File ".\sublime_plugin.py", line 62, in reload_plugin m = imp.load_module(modulename, *m_info) File ".\SublimeCodeIntel.py", line 93, in CODEINTEL_HOME_DIR = os.path.expanduser(os.path.join('~', '.codeintel')) File ".\ntpath.py", line 301, in expanduser UnicodeDecodeError: 'ascii' codec can't decode byte 0xd1 in position 9: ordinal not in range(128)

I think, maybe it happens cos the Windows Username has Cyrillic characters? So the path to the ST Packages is: "C:\Users\Света\AppData\Roaming\Sublime Text 2\Packages"

nicosantangelo commented 9 years ago

That could be it!

I'll give it a try and report back here

design-gur commented 9 years ago

Waiting for your try. Anyway thanks a lot!

nicosantangelo commented 9 years ago

Status update: I was able to reproduce the bug, I'll fix it as soon as I can!

EDIT The fix is up!, if you can, please let me know if it's working for you (I'm not really sure I have the right environment). It may take a bit for PackageControl to update, the tag with the fix is 4.3.1

design-gur commented 9 years ago

It didn't help me.

nicosantangelo commented 9 years ago

I finally got a VM with Windows working and confirmed that the bug was resolved on Unix but not in Windows. I'm working on it :)

design-gur commented 9 years ago

Thank you for your time. Waiting for your fix with the delight :-)

nicosantangelo commented 9 years ago

The new patch is up! If you don't mind, let me know if it works. I'm still not sure if my test environment is correct.

Thanks!

nicosantangelo commented 9 years ago

@design-gur Any news? :)

rickmills commented 9 years ago

We're having what seems like a very similar issue.

Basically one of our sass files has a funky graphic thing done in ascii characters. Whilst obviously it doesn't need to be there, the command like gulp command works fine.

Here's the error we're getting:

error /Users/.../src/scss/Site/some-file.scss (Line 5: Invalid US-ASCII character "\xE2")

On that line we have this:

/*═════╤═╤═════╤═╤═▒▓▓█████▓██▓▓█▓▓▓▒▒▒▓▓▓▒════╤═╤═════╤═╤═════╤═╤═════╤═╤═════╤╗

As I said, it's an ASCII art graphic and obviously is not needed. However if its causing issues with these, it's going to cause issues elsewhere.

What's more puzzling is why it's doing it at all. I mean, doesn't the subime-gulp plugin essentially do the same commands as we'd run via command line, just in a much more convenient way?

Really hope this is an easy fix as the plugin's awesome!

design-gur commented 9 years ago

Still actual :-(

nicosantangelo commented 9 years ago

@rmwebs The problem is piping the process output from the console to Sublime and supporting both Python 2.7 and 3 (for both sublime versions), the encoding goes a little crazy.

The "good" news is that I'm finally able to recreate the bug (both for this issue and #32 , created by @Sigmanor, which seem to be related). I hope I can get a fix working soon.

Thanks for your patience people!

nicosantangelo commented 9 years ago

@design-gur A fix for non-utf characters is up! Last version is v4.5.0, if you're using Package Control you can use the List packages command to check which version of sublime-gulp you have. Let me know how it goes, sorry for making you wait.

@rmwebs Can you open a new issue letting me know which gulp task are you running? So I can focus on fixing that having a good test scenario. Thanks!

design-gur commented 9 years ago

4.5.0 Still having the same problems. image

If you don't mind, can you explain me — what characters is he talking about (first line of output)? Something goes wrong in "gulpfile.js" or the trouble is in the path to the files?


Btw, I'm using the same copy of the project in WebStrom, and it works fine there. Not really sure that it can help to understand what goes wrong.

And sorry for the delay. Just tons of work.

nicosantangelo commented 9 years ago

If you don't mind, can you explain me — what characters is he talking about (first line of output)? Something goes wrong in "gulpfile.js" or the trouble is in the path to the files?

He's talking about a source file which has "weird" ASCII characters, so in that case it's not a problem with the gulpfile.js.

To make a recap of this issue, there were a couple of errors with encoding in this package that I wouldn't have found if it wasn't for this, thanks for that!. But you issue remains because it seems to be a problem with the encoding and your windows username (as you said before). I had hard time recreating it because the error comes from a Python library (not gulp), that's why it's a bit hard to fix, but I'm trying!

As a temporal fix, you try do the following: Save this file in the root of your project and then run the following in the terminal:

node write_tasks_to_cache.js .

That js creates the cache the package uses to run the tasks, if it works, you could try running Sublime gulp again.

One last thing! this problem seems to be Python < 2 specific, meaning that if you have SublimeText 3, it should work fine there :)


And sorry for the delay. Just tons of work.

Don't worry! I'm having a rough couple of weeks too.

nicosantangelo commented 9 years ago

@design-gur Sorry for the massive delay, I'm not having a lot of free time lately.

Finally I think this issue is resolved. If you don't mind, please give it a try on 4.5.2 and thanks for being patient

design-gur commented 9 years ago

Now running well! Thank you a lot for fixing it! Currently I can work in ST again. The only problem is that now I have to write the path to gulpfile.js using backslashes like: "gulpfile_paths": ["team\gulp"]

But it's really not a problem.