Thom1729 / Sublime-JS-Custom

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

Building Syntaxes Failing with Latest Version #129

Closed nwoltman closed 2 years ago

nwoltman commented 2 years ago

JSCustom recently updated to v4.2.1 (right after updating Sublime to build 4121) and now the syntaxes build fails. Removing the package and reinstalling doesn't help.

Here's the error message I'm getting after rebuilding syntaxes using the default config:

Building JS Custom.sublime-syntax.yaml-macros... (/Users/nwoltman/Library/Application Support/Sublime Text 3/Packages/JSCustom/src/syntax/JS Custom.sublime-syntax.yaml-macros)

Error in macro execution.
  in "<unicode string>", line 4, column 1:
    !apply
    ^ (line: 4)
{'name': 'JS Custom - Default', 'jsx': False, 'file_path': '/Users/nwoltman/Library/Application Support/Sublime Text 3/Packages/JSCustom/src/syntax/JS Custom.sublime-syntax.yaml-macros', 'custom_template_tags': False, 'scope': 'source.js.default', 'flow_types': False}

Error in macro execution.
  in "<unicode string>", line 6, column 5:
      - !get_extensions
        ^ (line: 6)
{'name': 'JS Custom - Default', 'jsx': False, 'file_path': '/Users/nwoltman/Library/Application Support/Sublime Text 3/Packages/JSCustom/src/syntax/JS Custom.sublime-syntax.yaml-macros', 'custom_template_tags': False, 'scope': 'source.js.default', 'flow_types': False}

Traceback (most recent call last):
  File "/Users/nwoltman/Library/Application Support/Sublime Text 3/Packages/yaml_macros_engine/st3/yamlmacros/src/custom_constructor.py", line 31, in macro_constructor
    return macro(loader, node)
  File "/Users/nwoltman/Library/Application Support/Sublime Text 3/Packages/yaml_macros_engine/st3/yamlmacros/src/get_macro.py", line 51, in macro
    result = apply(function, args)
  File "/Users/nwoltman/Library/Application Support/Sublime Text 3/Packages/yaml_macros_engine/st3/yamlmacros/src/util.py", line 27, in apply
    return fn(**fix_keywords(args))
  File "/Users/nwoltman/Library/Application Support/Sublime Text 3/Installed Packages/JSCustom.sublime-package/src/syntax/macros.py", line 19, in get_extensions
    name for name, options in configuration.items()
AttributeError: 'NoneType' object has no attribute 'items'

[Failed in 1.03 seconds.]

Building JS Custom.sublime-syntax.yaml-macros... (/Users/nwoltman/Library/Application Support/Sublime Text 3/Packages/JSCustom/src/syntax/JS Custom.sublime-syntax.yaml-macros)

Error in macro execution.
  in "<unicode string>", line 4, column 1:
    !apply
    ^ (line: 4)
{'typescript': True, 'name': 'JS Custom - TypeScript', 'jsx': False, 'custom_template_tags': False, 'scope': 'source.ts', 'flow_types': False, 'file_extensions': ['ts'], 'file_path': '/Users/nwoltman/Library/Application Support/Sublime Text 3/Packages/JSCustom/src/syntax/JS Custom.sublime-syntax.yaml-macros'}

Error in macro execution.
  in "<unicode string>", line 6, column 5:
      - !get_extensions
        ^ (line: 6)
{'typescript': True, 'name': 'JS Custom - TypeScript', 'jsx': False, 'custom_template_tags': False, 'scope': 'source.ts', 'flow_types': False, 'file_extensions': ['ts'], 'file_path': '/Users/nwoltman/Library/Application Support/Sublime Text 3/Packages/JSCustom/src/syntax/JS Custom.sublime-syntax.yaml-macros'}

Traceback (most recent call last):
  File "/Users/nwoltman/Library/Application Support/Sublime Text 3/Packages/yaml_macros_engine/st3/yamlmacros/src/custom_constructor.py", line 31, in macro_constructor
    return macro(loader, node)
  File "/Users/nwoltman/Library/Application Support/Sublime Text 3/Packages/yaml_macros_engine/st3/yamlmacros/src/get_macro.py", line 51, in macro
    result = apply(function, args)
  File "/Users/nwoltman/Library/Application Support/Sublime Text 3/Packages/yaml_macros_engine/st3/yamlmacros/src/util.py", line 27, in apply
    return fn(**fix_keywords(args))
  File "/Users/nwoltman/Library/Application Support/Sublime Text 3/Installed Packages/JSCustom.sublime-package/src/syntax/macros.py", line 19, in get_extensions
    name for name, options in configuration.items()
AttributeError: 'NoneType' object has no attribute 'items'

[Failed in 1.13 seconds.]

Building JS Custom.sublime-syntax.yaml-macros... (/Users/nwoltman/Library/Application Support/Sublime Text 3/Packages/JSCustom/src/syntax/JS Custom.sublime-syntax.yaml-macros)

Error in macro execution.
  in "<unicode string>", line 4, column 1:
    !apply
    ^ (line: 4)
{'file_extensions': ['js', 'jsx'], 'name': 'JS Custom - React', 'jsx': True, 'file_path': '/Users/nwoltman/Library/Application Support/Sublime Text 3/Packages/JSCustom/src/syntax/JS Custom.sublime-syntax.yaml-macros', 'custom_template_tags': False, 'scope': 'source.js.react', 'flow_types': True}

Error in macro execution.
  in "<unicode string>", line 6, column 5:
      - !get_extensions
        ^ (line: 6)
{'file_extensions': ['js', 'jsx'], 'name': 'JS Custom - React', 'jsx': True, 'file_path': '/Users/nwoltman/Library/Application Support/Sublime Text 3/Packages/JSCustom/src/syntax/JS Custom.sublime-syntax.yaml-macros', 'custom_template_tags': False, 'scope': 'source.js.react', 'flow_types': True}

Traceback (most recent call last):
  File "/Users/nwoltman/Library/Application Support/Sublime Text 3/Packages/yaml_macros_engine/st3/yamlmacros/src/custom_constructor.py", line 31, in macro_constructor
    return macro(loader, node)
  File "/Users/nwoltman/Library/Application Support/Sublime Text 3/Packages/yaml_macros_engine/st3/yamlmacros/src/get_macro.py", line 51, in macro
    result = apply(function, args)
  File "/Users/nwoltman/Library/Application Support/Sublime Text 3/Packages/yaml_macros_engine/st3/yamlmacros/src/util.py", line 27, in apply
    return fn(**fix_keywords(args))
  File "/Users/nwoltman/Library/Application Support/Sublime Text 3/Installed Packages/JSCustom.sublime-package/src/syntax/macros.py", line 19, in get_extensions
    name for name, options in configuration.items()
AttributeError: 'NoneType' object has no attribute 'items'

[Failed in 1.00 seconds.]

Building JS Custom.sublime-syntax.yaml-macros... (/Users/nwoltman/Library/Application Support/Sublime Text 3/Packages/JSCustom/src/syntax/JS Custom.sublime-syntax.yaml-macros)

Error in macro execution.
  in "<unicode string>", line 4, column 1:
    !apply
    ^ (line: 4)
{'name': 'JS Custom (Embedded)', 'jsx': False, 'custom_template_tags': False, 'scope': 'source.js', 'flow_types': False, 'file_extensions': [], 'hidden': True, 'file_path': '/Users/nwoltman/Library/Application Support/Sublime Text 3/Packages/JSCustom/src/syntax/JS Custom.sublime-syntax.yaml-macros', 'custom_templates': False}

Error in macro execution.
  in "<unicode string>", line 6, column 5:
      - !get_extensions
        ^ (line: 6)
{'name': 'JS Custom (Embedded)', 'jsx': False, 'custom_template_tags': False, 'scope': 'source.js', 'flow_types': False, 'file_extensions': [], 'hidden': True, 'file_path': '/Users/nwoltman/Library/Application Support/Sublime Text 3/Packages/JSCustom/src/syntax/JS Custom.sublime-syntax.yaml-macros', 'custom_templates': False}

Traceback (most recent call last):
  File "/Users/nwoltman/Library/Application Support/Sublime Text 3/Packages/yaml_macros_engine/st3/yamlmacros/src/custom_constructor.py", line 31, in macro_constructor
    return macro(loader, node)
  File "/Users/nwoltman/Library/Application Support/Sublime Text 3/Packages/yaml_macros_engine/st3/yamlmacros/src/get_macro.py", line 51, in macro
    result = apply(function, args)
  File "/Users/nwoltman/Library/Application Support/Sublime Text 3/Packages/yaml_macros_engine/st3/yamlmacros/src/util.py", line 27, in apply
    return fn(**fix_keywords(args))
  File "/Users/nwoltman/Library/Application Support/Sublime Text 3/Installed Packages/JSCustom.sublime-package/src/syntax/macros.py", line 19, in get_extensions
    name for name, options in configuration.items()
AttributeError: 'NoneType' object has no attribute 'items'

[Failed in 1.07 seconds.]

Building JS Custom.sublime-syntax.yaml-macros... (/Users/nwoltman/Library/Application Support/Sublime Text 3/Packages/JSCustom/src/syntax/JS Custom.sublime-syntax.yaml-macros)

Error in macro execution.
  in "<unicode string>", line 4, column 1:
    !apply
    ^ (line: 4)
{'typescript': True, 'name': 'JS Custom - TypeScript (JSX)', 'jsx': True, 'custom_template_tags': False, 'scope': 'source.tsx', 'flow_types': False, 'file_extensions': ['tsx'], 'file_path': '/Users/nwoltman/Library/Application Support/Sublime Text 3/Packages/JSCustom/src/syntax/JS Custom.sublime-syntax.yaml-macros'}

Error in macro execution.
  in "<unicode string>", line 6, column 5:
      - !get_extensions
        ^ (line: 6)
{'typescript': True, 'name': 'JS Custom - TypeScript (JSX)', 'jsx': True, 'custom_template_tags': False, 'scope': 'source.tsx', 'flow_types': False, 'file_extensions': ['tsx'], 'file_path': '/Users/nwoltman/Library/Application Support/Sublime Text 3/Packages/JSCustom/src/syntax/JS Custom.sublime-syntax.yaml-macros'}

Traceback (most recent call last):
  File "/Users/nwoltman/Library/Application Support/Sublime Text 3/Packages/yaml_macros_engine/st3/yamlmacros/src/custom_constructor.py", line 31, in macro_constructor
    return macro(loader, node)
  File "/Users/nwoltman/Library/Application Support/Sublime Text 3/Packages/yaml_macros_engine/st3/yamlmacros/src/get_macro.py", line 51, in macro
    result = apply(function, args)
  File "/Users/nwoltman/Library/Application Support/Sublime Text 3/Packages/yaml_macros_engine/st3/yamlmacros/src/util.py", line 27, in apply
    return fn(**fix_keywords(args))
  File "/Users/nwoltman/Library/Application Support/Sublime Text 3/Installed Packages/JSCustom.sublime-package/src/syntax/macros.py", line 19, in get_extensions
    name for name, options in configuration.items()
AttributeError: 'NoneType' object has no attribute 'items'

[Failed in 1.01 seconds.]
Thom1729 commented 2 years ago

I can't reproduce in my regular environment. What version of Sublime are you running?

nwoltman commented 2 years ago

I'm on the most recent stable version of Sublime, build 4121.

Thom1729 commented 2 years ago

I'm on 4120, which should be identical. I tried on a fresh 4121 install, and could not reproduce there either.

This is a weird thing to be happening. It looks like the get_extensions macro is getting a configuration argument of None. That should be impossible.

Can you run the following in the Python 3.3 console and paste the result?

import JSCustom.src.configurations; JSCustom.src.configurations.get_configurations(sublime.load_settings('JS Custom.sublime-settings'))
navandstokes commented 2 years ago

I had this error with build 4121 as well. The error is gone after restarting and rebuilding syntaxes (with no project open).

Thom1729 commented 2 years ago

I'm at a loss. I can't think if any reason why configuration should be None there. And without any hypothesis as to what might be wrong, I can't reproduce it, either. I was just about ready to chalk it down to cosmic rays or something, except that at least two people are having the problem.

@nwoltman When you run the rebuild command, are there any errors in the Python console?

nwoltman commented 2 years ago

Can you run the following in the Python 3.3 console and paste the result?

import JSCustom.src.configurations; JSCustom.src.configurations.get_configurations(sublime.load_settings('JS Custom.sublime-settings'))

This is what I get when I run that in the console:

>>> import JSCustom.src.configurations; JSCustom.src.configurations.get_configurations(sublime.load_settings('JS Custom.sublime-settings'))
import JSCustom.src.configurations; JSCustom.src.configurations.get_configurations(sublime.load_settings('JS Custom.sublime-settings'))
import JSCustom.src.configurations; JSCustom.src.configurations.get_configurations(sublime.load_settings('JS Custom.sublime-settings'))
import JSCustom.src.configurations; JSCustom.src.configurations.get_configurations(sublime.load_settings('JS Custom.sublime-settings'))
import JSCustom.src.configurations; JSCustom.src.configurations.get_configurations(sublime.load_settings('JS Custom.sublime-settings'))
import JSCustom.src.configurations; JSCustom.src.configurations.get_configurations(sublime.load_settings('JS Custom.sublime-settings'))
import JSCustom.src.configurations; JSCustom.src.configurations.get_configurations(sublime.load_settings('JS Custom.sublime-settings'))
Traceback (most recent call last):
  File "__main__", line 1, in <module>
ModuleNotFoundError: No module named 'JSCustom'

After trying to rebuild syntaxes and then opening the Python console, here's what I'm seeing:

[JS Custom] Building configuration Default…
[JS Custom] Building configuration TypeScript…
error parsing lexer: Packages/User/JS Custom/Syntaxes/Default.sublime-syntax: Error trying to parse sublime-syntax: %YAML indicator is required in Packages/User/JS Custom/Syntaxes/Default.sublime-syntax:1:1
error parsing lexer: Packages/User/JS Custom/Syntaxes/React.sublime-syntax: Error trying to parse sublime-syntax: %YAML indicator is required in Packages/User/JS Custom/Syntaxes/React.sublime-syntax:1:1
error parsing lexer: Packages/User/JS Custom/Syntaxes/TypeScript.sublime-syntax: Error trying to parse sublime-syntax: %YAML indicator is required in Packages/User/JS Custom/Syntaxes/TypeScript.sublime-syntax:1:1
error parsing lexer: Packages/User/JS Custom/Syntaxes/TypeScript (JSX).sublime-syntax: Error trying to parse sublime-syntax: %YAML indicator is required in Packages/User/JS Custom/Syntaxes/TypeScript (JSX).sublime-syntax:1:1
error parsing lexer: Packages/User/JS Custom/Syntaxes/~embed.sublime-syntax: Error trying to parse sublime-syntax: %YAML indicator is required in Packages/User/JS Custom/Syntaxes/~embed.sublime-syntax:1:1
generating syntax summary
error: Error loading syntax file "Packages/User/JS Custom/Syntaxes/Default.sublime-syntax": Error trying to parse sublime-syntax: %YAML indicator is required in Packages/User/JS Custom/Syntaxes/Default.sublime-syntax:1:1
[JS Custom] Building configuration React…
[JS Custom] Building configuration ~embed…
[JS Custom] Building configuration TypeScript (JSX)…
error parsing lexer: Packages/User/JS Custom/Syntaxes/Default.sublime-syntax: Error trying to parse sublime-syntax: %YAML indicator is required in Packages/User/JS Custom/Syntaxes/Default.sublime-syntax:1:1
error parsing lexer: Packages/User/JS Custom/Syntaxes/React.sublime-syntax: Error trying to parse sublime-syntax: %YAML indicator is required in Packages/User/JS Custom/Syntaxes/React.sublime-syntax:1:1
error parsing lexer: Packages/User/JS Custom/Syntaxes/TypeScript.sublime-syntax: Error trying to parse sublime-syntax: %YAML indicator is required in Packages/User/JS Custom/Syntaxes/TypeScript.sublime-syntax:1:1
error parsing lexer: Packages/User/JS Custom/Syntaxes/TypeScript (JSX).sublime-syntax: Error trying to parse sublime-syntax: %YAML indicator is required in Packages/User/JS Custom/Syntaxes/TypeScript (JSX).sublime-syntax:1:1
error parsing lexer: Packages/User/JS Custom/Syntaxes/~embed.sublime-syntax: Error trying to parse sublime-syntax: %YAML indicator is required in Packages/User/JS Custom/Syntaxes/~embed.sublime-syntax:1:1
generating syntax summary
indexing [job 61]: no files were indexed out of the 4096 queued, abandoning crawl
error parsing lexer: Packages/User/JS Custom/Syntaxes/Default.sublime-syntax: Error trying to parse sublime-syntax: %YAML indicator is required in Packages/User/JS Custom/Syntaxes/Default.sublime-syntax:1:1
error parsing lexer: Packages/User/JS Custom/Syntaxes/React.sublime-syntax: Error trying to parse sublime-syntax: %YAML indicator is required in Packages/User/JS Custom/Syntaxes/React.sublime-syntax:1:1
error parsing lexer: Packages/User/JS Custom/Syntaxes/TypeScript.sublime-syntax: Error trying to parse sublime-syntax: %YAML indicator is required in Packages/User/JS Custom/Syntaxes/TypeScript.sublime-syntax:1:1
error parsing lexer: Packages/User/JS Custom/Syntaxes/TypeScript (JSX).sublime-syntax: Error trying to parse sublime-syntax: %YAML indicator is required in Packages/User/JS Custom/Syntaxes/TypeScript (JSX).sublime-syntax:1:1
error parsing lexer: Packages/User/JS Custom/Syntaxes/~embed.sublime-syntax: Error trying to parse sublime-syntax: %YAML indicator is required in Packages/User/JS Custom/Syntaxes/~embed.sublime-syntax:1:1
generating syntax summary

Although update: It's building just fine now. Fully closing Sublime and restarting fixed it. I guess I hadn't quit Sublime or restarted my computer in a few days.

Thom1729 commented 2 years ago

Those are some pretty wild errors. It looks like there was some kind of problem with Sublime reading the package files. Whatever the root cause was, I suspect it had something to do with the fact that Python isn't really designed for hot module reloading. If restarting Sublime fixed it, then I'm not overly concerned.

If the problem recurs, feel free to repoen.