Thom1729 / Sublime-JS-Custom

Customizable JavaScript syntax highlighting for Sublime Text.
MIT License
137 stars 9 forks source link

JSCustom errors in Sublime Text stable build 4107 #121

Closed Shelagh-Lewins closed 3 years ago

Shelagh-Lewins commented 3 years ago

Upgrading Sublime Text seems to have broken your beautiful plugin.

I just upgraded from ST3 to build 4107 on Linux mint. This seems to be the first stable release of ST4?

ST complained that JS Custom needed to be uninistalled and reinstalled, so I did that using Package Control.

I am seeing this error in the console:


Traceback (most recent call last):
  File "/opt/sublime_text/Lib/python33/sublime_plugin.py", line 308, in reload_plugin
    m = importlib.import_module(modulename)
  File "./python3.3/importlib/__init__.py", line 90, in import_module
  File "<frozen importlib._bootstrap>", line 1584, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1565, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1532, in _find_and_load_unlocked
  File "/opt/sublime_text/Lib/python33/sublime_plugin.py", line 1692, in load_module
    exec(compile(source, source_path, 'exec'), mod.__dict__)
  File "/home/user/.config/sublime-text-3/Installed Packages/JSCustom.sublime-package/plugin.py", line 12, in <module>
  File "/opt/sublime_text/Lib/python33/sublime_plugin.py", line 1692, in load_module
    exec(compile(source, source_path, 'exec'), mod.__dict__)
  File "/home/user/.config/sublime-text-3/Installed Packages/JSCustom.sublime-package/src/commands/build_syntaxes.py", line 10, in <module>
  File "/opt/sublime_text/Lib/python33/sublime_plugin.py", line 1692, in load_module
    exec(compile(source, source_path, 'exec'), mod.__dict__)
  File "/home/user/.config/sublime-text-3/Installed Packages/JSCustom.sublime-package/src/build.py", line 2, in <module>
ImportError: No module named 'yamlmacros'

...

Package Control: Installing 1 missing dependency
Package Control: Installed missing dependency yaml_macros_engine
Package Control: Skipping automatic upgrade, last run at 2021-06-08 09:11:24, next run at 2021-06-08 10:11:24 or after
error: Package Control

1 missing dependency was just installed. Sublime Text should be restarted, otherwise one or more of the installed packages may not function properly.

When Sublime Text opens, a popup appears saying that there is an error loading syntax file, unable to read TypeSciprt(JSX).sublime-syntax.

So, JS Custom is installed, but is not reading the syntax files?

I'm not sure if the issues are with JS Custom, or ST4 itself; Package Control is very slow and unreliable for me in the new version.

Thom1729 commented 3 years ago

Try restarting Sublime and running “JS Custom: Rebuild Syntaxes” from the command palette.

Shelagh-Lewins commented 3 years ago

Thank you, that seems to have done the trick!

Thom1729 commented 3 years ago

Glad to hear it!

I'm not sure why it had to be uninstalled and reinstalled in the first place. Probably because it needed a newer version, but I'd think PC would just upgrade instead. Maybe it doesn't want to do an upgrade if the existing version is invalid because the package might run code during the upgrade event, and for an invalid version that could be problematic.

When it reinstalled, it couldn't find the yaml_macros_engine dependency. Presumably this dependency was uninstalled and reinstalled with JS Custom. Ordinarily, dependencies aren't loaded until restart (which is annoying), but JS Custom runs code on load to manually load its own dependencies if needed. Apparently it didn't work here. In your log, the dependency load notification is after the error, which implies that PC didn't even install yaml_macros_engine until after it tried to load JS Custom. That seems wrong. I haven't seen this exact issue before, so maybe the order of operations is wonky in this specific case. I probably can't work around that (if the dependency isn't installed, it isn't installed) but it might be possible to improve the error handling. I most likely won't bother because a) this only seems to be possible in this really specific situation, b) no one else has reported running into it, c) error handling code here would be a pain to test, d) the user-side fix is easy, and e) at some point JS Custom will be moving to the 3.8 runtime anyway and all this could be moot.