jdavisclark / JsFormat

Javascript formatting for Sublime Text 2 & 3
1.42k stars 222 forks source link

JsFormat not working on Sublime 3 since few days ago #170

Closed yorch closed 5 years ago

yorch commented 8 years ago

Hello,

Thanks for the plugin, really helpful.

Since few days ago, it has stopped working for me, it used to work fine but now I'm getting the following error in the console:

Traceback (most recent call last):
  File "/Applications/Sublime Text.app/Contents/MacOS/sublime_plugin.py", line 574, in run_
    return self.run(edit)
  File "js_formatter in /Users/yorch/Library/Application Support/Sublime Text 3/Installed Packages/JsFormat.sublime-package", line 88, in run
  File "/Users/yorch/Library/Application Support/Sublime Text 3/Installed Packages/JsFormat.sublime-package/src/jsf.py", line 79, in format_whole_file
  File "/Users/yorch/Library/Application Support/Sublime Text 3/Installed Packages/JsFormat.sublime-package/libs/jsbeautifier/jsbeautifier/__init__.py", line 234, in beautify
  File "/Users/yorch/Library/Application Support/Sublime Text 3/Installed Packages/JsFormat.sublime-package/libs/jsbeautifier/jsbeautifier/__init__.py", line 383, in beautify
  File "/Users/yorch/Library/Application Support/Sublime Text 3/Installed Packages/JsFormat.sublime-package/libs/jsbeautifier/jsbeautifier/__init__.py", line 1349, in __init__
  File "/Users/yorch/Library/Application Support/Sublime Text 3/Installed Packages/JsFormat.sublime-package/libs/jsbeautifier/jsbeautifier/__init__.py", line 154, in __init__
zipimport.ZipImportError: bad local file header in /Users/yorch/Library/Application Support/Sublime Text 3/Installed Packages/JsFormat.sublime-package

I've tried uninstalling and installing the package again but no luck.

Any clues?

Thanks

jdavisclark commented 8 years ago

@yorch this is a bug with package control + sublime, it has happened before here and with other plugins. I pushed out an update a couple days ago, and when Package Control tried to update the plugin it hit this bug, which results in a corrupt zip archive.

Try removing JsFormat, closing sublime (completely), and reinstalling. If that doesn't work, try a manual install without package control (just realize you won't get updates automatically)

wbond commented 8 years ago

This is most likely caused by https://github.com/jdc0589/JsFormat/blob/master/js_formatter.py#L30.

zipimport caches the file handle to do reloads. In this case, the old .sublime-package file is deleted, so the file handle is no longer valid.

I don't believe this really has anything to do with Sublime's ZipImport or Package Control. You may notice it with Package Control when hot-reloads happen during upgrade, but that is because you aren't removing your custom sys.path entries (and sys.modules entries) when the package is unloaded.

Most likely you should refactor JsFormat to use relative imports with Python 3 instead of messing with sys.path.

jdavisclark commented 8 years ago

@wbond. Thanks. Most of that was in there from the pre-ST3 days. I honestly don't know what kind of ST2 userbase is still even around. Does package control track those stats? I thought it might, but I'm not seeing anything.

tufandevrim commented 8 years ago

Same issue on selection as well

Traceback (most recent call last):
  File "/Applications/Sublime Text.app/Contents/MacOS/sublime_plugin.py", line 574, in run_
    return self.run(edit)
  File "js_formatter in /Users/dtufan/Library/Application Support/Sublime Text 3/Installed Packages/JsFormat.sublime-package", line 86, in run
  File "/Users/dtufan/Library/Application Support/Sublime Text 3/Installed Packages/JsFormat.sublime-package/src/jsf.py", line 53, in format_selection
  File "/Users/dtufan/Library/Application Support/Sublime Text 3/Installed Packages/JsFormat.sublime-package/libs/jsbeautifier/jsbeautifier/__init__.py", line 234, in beautify
  File "/Users/dtufan/Library/Application Support/Sublime Text 3/Installed Packages/JsFormat.sublime-package/libs/jsbeautifier/jsbeautifier/__init__.py", line 383, in beautify
  File "/Users/dtufan/Library/Application Support/Sublime Text 3/Installed Packages/JsFormat.sublime-package/libs/jsbeautifier/jsbeautifier/__init__.py", line 1349, in __init__
  File "/Users/dtufan/Library/Application Support/Sublime Text 3/Installed Packages/JsFormat.sublime-package/libs/jsbeautifier/jsbeautifier/__init__.py", line 154, in __init__
zipimport.ZipImportError: bad local file header in /Users/dtufan/Library/Application Support/Sublime Text 3/Installed Packages/JsFormat.sublime-package
patik commented 7 years ago

Just started a few days ago for me:

Package Control: Error downloading package. HTTP error 403 downloading https://codeload.github.com/jdc0589/JsFormat/zip/master.

Notice the codeload sub-domain, which doesn't resolve.

jdavisclark commented 7 years ago

@patik I think what you are experiencing is a different issue. That looks like Package Control territory.

wbond commented 7 years ago

@patik If the domain didn't resolve, you wouldn't get a 403. I can download that URL without issue, so it is likely something else.

I would start with https://packagecontrol.io/docs/troubleshooting#Purging_and_Reinstalling and then try https://packagecontrol.io/docs/troubleshooting#Enabling_the_Debug_Log.

If you continue to have issues, and you think it is an issue with Package Control, open an issue at https://github.com/wbond/package_control/issues/new.

jdavisclark commented 7 years ago

@patik I missed the bit about it being a 403. But for the record, I also could not hit that url when you originally commented. It seems to work fine now though.

onlynight commented 6 years ago

i have same problem too, how can i fix it, thanks.

Package Control: Error downloading package.
HTTP error 404 downloading https://codeload.github.com/jdc0589/JsFormat/zip/master.

this https://codeload.github.com/jdc0589/JsFormat/zip/master link is actually 404, should i update package control or anything?

bitwiseman commented 5 years ago

It looks like this was fixed. Thanks @ash14!