Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LSP can not start #1656

Closed
husanjun opened this issue May 7, 2021 · 16 comments
Closed

LSP can not start #1656

husanjun opened this issue May 7, 2021 · 16 comments

Comments

@husanjun
Copy link
Contributor

husanjun commented May 7, 2021

Describe the bug

Failed to register plugin ""
Traceback (most recent call last):
  File "F:\Sublime Text\Data\Installed Packages\LSP.sublime-package\plugin/core/sessions.py", line 641, in _register_plugin_impl
    if client_configs.add_external_config(name, settings, base_file, notify_listener):
  File "F:\Sublime Text\Data\Installed Packages\LSP.sublime-package\plugin/core/settings.py", line 37, in add_external_config
    config = ClientConfig.from_sublime_settings(name, s, file)
  File "F:\Sublime Text\Data\Installed Packages\LSP.sublime-package\plugin/core/types.py", line 564, in from_sublime_settings
    base = sublime.decode_value(sublime.load_resource(file))
  File "F:\Sublime Text\Lib\python33\sublime.py", line 435, in load_resource
    raise IOError('resource "%s" not found' % name)
OSError: resource "Packages//.sublime-settings" not found

Environment (please complete the following information):

  • OS: win7
  • Sublime Text version: 4104
  • LSP version: 1.3.0
  • Language servers used: [e.g. clangd, gopls, dart, Vetur, intelephense, HIE]
@rchl
Copy link
Member

rchl commented May 7, 2021

Something wrong in your LSP.sublime-settings possibly. Feel free to post it.

@husanjun
Copy link
Contributor Author

husanjun commented May 7, 2021

All packages are reporting errors that seem to be a dependency problem

reloading python 3.3 plugin LSP-json.plugin
Traceback (most recent call last):
  File "F:\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 "F:\Sublime Text\Lib\python33\sublime_plugin.py", line 1692, in load_module
    exec(compile(source, source_path, 'exec'), mod.__dict__)
  File "F:\Sublime Text\Data\Installed Packages\LSP-json.sublime-package\plugin.py", line 5, in <module>
  File "F:\SUBLIM~2\Data\Packages\LSP_UT~1\st3\lsp_utils\__init__.py", line 8, in <module>
    from .npm_client_handler import NpmClientHandler
  File "F:\SUBLIM~2\Data\Packages\LSP_UT~1\st3\lsp_utils\npm_client_handler.py", line 2, in <module>
    from .server_npm_resource import ServerNpmResource
  File "F:\SUBLIM~2\Data\Packages\LSP_UT~1\st3\lsp_utils\server_npm_resource.py", line 8, in <module>
    from sublime_lib import ResourcePath
  File "F:\SUBLIM~2\Data\Packages\SUBLIM~1\st3\sublime_lib\__init__.py", line 10, in <module>
    from .region_manager import RegionManager  # noqa: F401
  File "F:\SUBLIM~2\Data\Packages\SUBLIM~1\st3\sublime_lib\region_manager.py", line 3, in <module>
    from ._compat.typing import Optional, List, TypeVar, Collection
ImportError: cannot import name Collection
reloading python 3.3 plugin LSP-pyls.plugin
Traceback (most recent call last):
  File "F:\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 "F:\Sublime Text\Lib\python33\sublime_plugin.py", line 1692, in load_module
    exec(compile(source, source_path, 'exec'), mod.__dict__)
  File "F:\Sublime Text\Data\Installed Packages\LSP-pyls.sublime-package\plugin.py", line 2, in <module>
  File "F:\SUBLIM~2\Data\Packages\LSP_UT~1\st3\lsp_utils\__init__.py", line 8, in <module>
    from .npm_client_handler import NpmClientHandler
  File "F:\SUBLIM~2\Data\Packages\LSP_UT~1\st3\lsp_utils\npm_client_handler.py", line 2, in <module>
    from .server_npm_resource import ServerNpmResource
  File "F:\SUBLIM~2\Data\Packages\LSP_UT~1\st3\lsp_utils\server_npm_resource.py", line 8, in <module>
    from sublime_lib import ResourcePath
  File "F:\SUBLIM~2\Data\Packages\SUBLIM~1\st3\sublime_lib\__init__.py", line 10, in <module>
    from .region_manager import RegionManager  # noqa: F401
  File "F:\SUBLIM~2\Data\Packages\SUBLIM~1\st3\sublime_lib\region_manager.py", line 3, in <module>
    from ._compat.typing import Optional, List, TypeVar, Collection
ImportError: cannot import name Collection
reloading python 3.3 plugin LSP-typescript.plugin
Traceback (most recent call last):
  File "F:\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 "F:\Sublime Text\Lib\python33\sublime_plugin.py", line 1692, in load_module
    exec(compile(source, source_path, 'exec'), mod.__dict__)
  File "F:\Sublime Text\Data\Installed Packages\LSP-typescript.sublime-package\plugin.py", line 7, in <module>
  File "F:\SUBLIM~2\Data\Packages\LSP_UT~1\st3\lsp_utils\__init__.py", line 8, in <module>
    from .npm_client_handler import NpmClientHandler
  File "F:\SUBLIM~2\Data\Packages\LSP_UT~1\st3\lsp_utils\npm_client_handler.py", line 2, in <module>
    from .server_npm_resource import ServerNpmResource
  File "F:\SUBLIM~2\Data\Packages\LSP_UT~1\st3\lsp_utils\server_npm_resource.py", line 8, in <module>
    from sublime_lib import ResourcePath
  File "F:\SUBLIM~2\Data\Packages\SUBLIM~1\st3\sublime_lib\__init__.py", line 10, in <module>
    from .region_manager import RegionManager  # noqa: F401
  File "F:\SUBLIM~2\Data\Packages\SUBLIM~1\st3\sublime_lib\region_manager.py", line 3, in <module>
    from ._compat.typing import Optional, List, TypeVar, Collection
ImportError: cannot import name Collection

@husanjun
Copy link
Contributor Author

husanjun commented May 7, 2021

I noticed that sublime_lib has just been upgraded, I don't know if that's why

@rchl
Copy link
Member

rchl commented May 7, 2021

Not sure. It works here with the latest sublime_lib version.
But I'm on Mac.

@jfcherng
Copy link
Contributor

jfcherng commented May 7, 2021

It failed on my side too after I manually update sublime_lib to https://github.com/SublimeText/sublime_lib/releases/tag/v1.5.1


Manually rollbacked to v1.5.0.

@husanjun
Copy link
Contributor Author

husanjun commented May 7, 2021

I looked at the source code for sublime_lib
image

I deleted the local dependency typing, LSP worked normally, but after restarting ST, typing was installed automatically, and the problem appeared again

@rchl
Copy link
Member

rchl commented May 7, 2021

The typing dependency must come from some other package and that is probably the main reason why it breaks.

Well, maybe not the main but at least part of the problem.

@jfcherng
Copy link
Contributor

jfcherng commented May 7, 2021

The typing dependency must come from some other package and that is probably the main reason why it breaks.

Yes, there is no Collection in typing with py33 (which means https://github.com/packagecontrol/typing/blob/v3.7.4/st3/typing.py#L1830 won't be True)... hence the error.

Python 3.3>>> import typing
Python 3.3>>> dir(typing)
['AbstractSet', 'Any', 'AnyStr', 'BinaryIO', 'ByteString', 'CT_co', 'Callable', 'CallableMeta', 'ChainMap', 'ClassVar', 'Container', 'ContextManager', 'Counter', 'DefaultDict', 'Deque', 'Dict', 'FrozenSet', 'Generator', 'Generic', 'GenericMeta', 'Hashable', 'IO', 'ItemsView', 'Iterable', 'Iterator', 'KT', 'KeysView', 'List', 'Mapping', 'MappingView', 'Match', 'MethodDescriptorType', 'MethodWrapperType', 'MutableMapping', 'MutableSequence', 'MutableSet', 'NamedTuple', 'NamedTupleMeta', 'NewType', 'NoReturn', 'Optional', 'Pattern', 'Reversible', 'Sequence', 'Set', 'Sized', 'SupportsAbs', 'SupportsBytes', 'SupportsComplex', 'SupportsFloat', 'SupportsIndex', 'SupportsInt', 'SupportsRound', 'T', 'TYPE_CHECKING', 'T_co', 'T_contra', 'Text', 'TextIO', 'Tuple', 'TupleMeta', 'Type', 'TypeVar', 'TypingMeta', 'Union', 'VT', 'VT_co', 'V_co', 'ValuesView', 'WrapperDescriptorType', '_Any', '_ClassVar', '_FinalTypingBase', '_ForwardRef', '_G_base', '_NoReturn', '_Optional', '_PY36', '_Protocol', '_ProtocolMeta', '_TypeAlias', '_TypingBase', '_TypingEllipsis', '_TypingEmpty', '_Union', '__all__', '__builtins__', '__cached__', '__doc__', '__file__', '__initializing__', '__loader__', '__name__', '__package__', '_allowed_types', '_check_generic', '_cleanups', '_eval_type', '_generic_new', '_get_defaults', '_get_type_vars', '_make_nmtuple', '_make_subclasshook', '_next_in_mro', '_no_slots_copy', '_overload_dummy', '_prohibited', '_qualname', '_remove_dups_flatten', '_replace_arg', '_special', '_subs_tree', '_tp_cache', '_trim_name', '_type_check', '_type_repr', '_type_vars', 'abc', 'abstractmethod', 'abstractproperty', 'cast', 'collections', 'collections_abc', 'contextlib', 'functools', 'get_type_hints', 'io', 'no_type_check', 'no_type_check_decorator', 'overload', 're', 'stdlib_re', 'sys', 'types']

@rwols
Copy link
Member

rwols commented May 7, 2021

What is typing.__file__ ?

@jfcherng
Copy link
Contributor

jfcherng commented May 7, 2021

What is typing.__file__ ?

Python 3.3>>> typing.__file__
'C:\\Users\\jfcherng\\AppData\\Roaming\\SUBLIM~2\\Packages\\typing\\st3\\typing.py'

@jwortmann
Copy link
Member

The typing dependency must come from some other package and that is probably the main reason why it breaks.

Does that mean LSP doesn't work if users have any other package installed which use the typing dependency?

By the way, why does LSP come with its own "implementation" of typing, instead of using the dependency from Package Control?

@rchl
Copy link
Member

rchl commented May 7, 2021

I might be wrong because I didn't study its code carefully but it seems like the typing dependency doesn't fall back to native typing when available (only does that for some stuff like collections). That causes issues when using LSP since those are not the same types as the native ones so there are type conflicts.

CC @FichteFoll

@husanjun
Copy link
Contributor Author

husanjun commented May 7, 2021

Does that mean LSP doesn't work if users have any other package installed which use the typing dependency?

Stay sublime_lib v1.5.0 it is also working

@jfcherng
Copy link
Contributor

jfcherng commented May 7, 2021

sublime_lib v1.5.2 is fine in my local test.

@husanjun
Copy link
Contributor Author

husanjun commented May 8, 2021

sublime_lib v1.5.2 is fine in my local test.

Thank you. I'll close it

@husanjun husanjun closed this as completed May 8, 2021
@rwols
Copy link
Member

rwols commented May 8, 2021

why does LSP come with its own "implementation" of typing, instead of using the dependency from Package Control?

Mypy types were first used on August 27, 2017: 875f54c

The first commit of the PC typing module was in 2018: packagecontrol/typing@0849c8c

The plugin/core/typing.py file was first created at the beginning of 2020: 9a009d6

LSP could perhaps make use of the PC typing module, but I think we can skip that step once we have migrated to python 3.8: #1389

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants