ligershark / Kulture

Sublime extension for ASP.NET vNext
Other
236 stars 30 forks source link

Kulture.py fails to parse unicode project.json #25

Closed lnaie closed 10 years ago

lnaie commented 10 years ago

It rather likes WE Windows 1252 file encoding than UTF-8. And once it has failed, then it keeps the file locked.

For better tooling, Thx

sayedihashimi commented 10 years ago

Can you provide a sample that reproduces the error?

marcuslindblom commented 10 years ago

I'm experiencing the same problem. This is the actual error in the console of Sublime Text 3

checking for project.json at: [/Users/maqe/Sites/vnext/app/BrickPile.UI/project.json]
project.json found at: [/Users/maqe/Sites/vnext/app/BrickPile.UI/project.json]
Traceback (most recent call last):
  File "/Applications/Sublime Text.app/Contents/MacOS/sublime_plugin.py", line 526, in run_
    return self.run()
  File "/Users/maqe/Library/Application Support/Sublime Text 3/Packages/Kulture/Kulture.py", line 212, in run
    json_file = json.load(open(file_name))
  File "./json/__init__.py", line 271, in load
  File "./encodings/ascii.py", line 26, in decode
UnicodeDecodeError: 'ascii' codec can't decode byte 0xef in position 0: ordinal not in range(128)

this is my project.json file:

{
    "dependencies": {
        "Kestrel": "1.0.0-*",
        "Microsoft.AspNet.Server.IIS": "1.0.0-alpha2",
        "Microsoft.AspNet.Mvc": "6.0.0-alpha2-*",
        "Microsoft.AspNet.Mvc.Core": "6.0.0-alpha2-*",
        "RavenDB.Client": "3.0.3424-Unstable",        
        "BrickPile": "0.0.1-alpha"
    },
    "configurations" : {
        "net451" : { },
        "k10" : { }
    },
    "commands": {
        "web": "Microsoft.AspNet.Hosting --server Microsoft.AspNet.Server.WebListener --server.urls http://localhost:5000",
         "kestrel": "Microsoft.AspNet.Hosting --server Kestrel --server.urls http://localhost:5004"
    }
}
sayedihashimi commented 10 years ago

Since its an encoding issue can you share the actual file?

marcuslindblom commented 10 years ago

Unfortunately I couldn't upload the file to this issue but maybe this is ok? http://cl.ly/XI7j

Edit: updated the link so now it's a zip with the actual file

lnaie commented 10 years ago

This is one of those, I had to fix: https://github.com/aspnet/BugTracker/blob/master/src/BugTracker/project.json

sayedihashimi commented 10 years ago

After looking into the exception there doesn't seem to be a straight forward way for me to know the encoding ahead of time.

We can detect it and give the user an error message with a next step to resolve the issue. I've checked in a fix into the master branch in commit 44cb9b0638e56f0ecd2bb8ce926bc701836f301d.

2014-08-30_17-03-08

Please try it out and let me know what you think.

If you have some suggestions as to how this could be handled better please let me know.

I'll leave this open for a bit before closing to see if there is any discussion.

marcuslindblom commented 10 years ago

I think it's good enough, I don't have any better solution.

sayedihashimi commented 10 years ago

Closing this now, if there are any suggestions on how to improve please reopen.