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

"Server initialization failed" with Poetry environment #93

Open
ivan-gj opened this issue Jul 31, 2023 · 6 comments
Open

"Server initialization failed" with Poetry environment #93

ivan-gj opened this issue Jul 31, 2023 · 6 comments
Assignees
Labels
info-needed Issue requires more information from poster triage-needed

Comments

@ivan-gj
Copy link

ivan-gj commented Jul 31, 2023

Using mypy v1.4.1 under a poetry environment (properly setup in VSCode project) and I get the following crash report right after VS Code is launched:

2023-07-31 13:07:26.631 [info] Interpreter from setting mypy-type-checker.interpreter: /home/user/.cache/pypoetry/virtualenvs/tariff-tools-sOhTbMWF-py3.7/bin/python
2023-07-31 13:07:26.631 [info] Using legacy Mypy args from 'python.linting.mypyArgs': --follow-imports=silent --ignore-missing-imports --show-column-numbers --no-pretty.
2023-07-31 13:07:26.631 [info] Server: Stop requested
2023-07-31 13:07:26.631 [error] Server: Stop failed: Error: Client is not running and can't be stopped. It's current state is: startFailed
2023-07-31 13:07:26.631 [info] Interpreter from setting mypy-type-checker.interpreter: /home/user/.cache/pypoetry/virtualenvs/tariff-tools-sOhTbMWF-py3.7/bin/python
2023-07-31 13:07:26.632 [info] Using legacy Mypy args from 'python.linting.mypyArgs': --follow-imports=silent --ignore-missing-imports --show-column-numbers --no-pretty.
2023-07-31 13:07:26.635 [info] Server run command: /home/user/.cache/pypoetry/virtualenvs/tariff-tools-sOhTbMWF-py3.7/bin/python /home/user/.vscode/extensions/ms-python.mypy-type-checker-2023.1.12061012/bundled/tool/lsp_server.py
2023-07-31 13:07:26.636 [info] Server: Start requested.
2023-07-31 13:07:27.417 [info] Traceback (most recent call last):
  File "/home/user/.vscode/extensions/ms-python.mypy-type-checker-2023.1.12061012/bundled/tool/lsp_server.py", line 49, in <module>
    name="Mypy", version="v0.1.0", max_workers=MAX_WORKERS
TypeError: __init__() got an unexpected keyword argument 'name'

2023-07-31 13:07:27.533 [info] [Error - 13:07:27] Server initialization failed.
2023-07-31 13:07:27.533 [info]   Message: Pending response rejected since connection got disposed
  Code: -32097 
2023-07-31 13:07:27.533 [info] [Info  - 13:07:27] Connection to server got closed. Server will restart.
2023-07-31 13:07:27.533 [info] true
2023-07-31 13:07:27.533 [info] [Error - 13:07:27] Mypy Type Checker client: couldn't create connection to server.
2023-07-31 13:07:27.533 [info]   Message: Pending response rejected since connection got disposed
  Code: -32097 
2023-07-31 13:07:28.275 [info] Traceback (most recent call last):
  File "/home/user/.vscode/extensions/ms-python.mypy-type-checker-2023.1.12061012/bundled/tool/lsp_server.py", line 49, in <module>
    name="Mypy", version="v0.1.0", max_workers=MAX_WORKERS
TypeError: __init__() got an unexpected keyword argument 'name'

2023-07-31 13:07:28.381 [info] [Error - 13:07:28] Server initialization failed.
2023-07-31 13:07:28.381 [info]   Message: Pending response rejected since connection got disposed
  Code: -32097 
2023-07-31 13:07:28.381 [info] [Info  - 13:07:28] Connection to server got closed. Server will restart.
2023-07-31 13:07:28.381 [info] true
2023-07-31 13:07:28.381 [info] [Error - 13:07:28] Mypy Type Checker client: couldn't create connection to server.
2023-07-31 13:07:28.381 [info]   Message: Pending response rejected since connection got disposed
  Code: -32097 
2023-07-31 13:07:28.382 [error] Server: Start failed: Error: Pending response rejected since connection got disposed
2023-07-31 13:07:29.149 [info] Traceback (most recent call last):
  File "/home/user/.vscode/extensions/ms-python.mypy-type-checker-2023.1.12061012/bundled/tool/lsp_server.py", line 49, in <module>
    name="Mypy", version="v0.1.0", max_workers=MAX_WORKERS
TypeError: __init__() got an unexpected keyword argument 'name'

2023-07-31 13:07:29.251 [info] [Error - 13:07:29] Server initialization failed.
2023-07-31 13:07:29.251 [info]   Message: Pending response rejected since connection got disposed
  Code: -32097 
2023-07-31 13:07:29.251 [info] [Info  - 13:07:29] Connection to server got closed. Server will restart.
2023-07-31 13:07:29.251 [info] true
2023-07-31 13:07:29.252 [info] [Error - 13:07:29] Mypy Type Checker client: couldn't create connection to server.
2023-07-31 13:07:29.252 [info]   Message: Pending response rejected since connection got disposed
  Code: -32097 
2023-07-31 13:07:29.252 [info] [Error - 13:07:29] Restarting server failed
2023-07-31 13:07:29.252 [info]   Message: Pending response rejected since connection got disposed
  Code: -32097 
2023-07-31 13:07:30.002 [info] Traceback (most recent call last):
  File "/home/user/.vscode/extensions/ms-python.mypy-type-checker-2023.1.12061012/bundled/tool/lsp_server.py", line 49, in <module>
    name="Mypy", version="v0.1.0", max_workers=MAX_WORKERS
TypeError: __init__() got an unexpected keyword argument 'name'

2023-07-31 13:07:30.094 [info] [Error - 13:07:30] Server initialization failed.
2023-07-31 13:07:30.094 [info]   Message: Pending response rejected since connection got disposed
  Code: -32097 
2023-07-31 13:07:30.094 [info] [Info  - 13:07:30] Connection to server got closed. Server will restart.
2023-07-31 13:07:30.094 [info] true
2023-07-31 13:07:30.095 [info] [Error - 13:07:30] Mypy Type Checker client: couldn't create connection to server.
2023-07-31 13:07:30.095 [info]   Message: Pending response rejected since connection got disposed
  Code: -32097 
2023-07-31 13:07:30.095 [info] [Error - 13:07:30] Restarting server failed
2023-07-31 13:07:30.095 [info]   Message: Pending response rejected since connection got disposed
  Code: -32097 
2023-07-31 13:07:30.835 [info] Traceback (most recent call last):
  File "/home/user/.vscode/extensions/ms-python.mypy-type-checker-2023.1.12061012/bundled/tool/lsp_server.py", line 49, in <module>
    name="Mypy", version="v0.1.0", max_workers=MAX_WORKERS
TypeError: __init__() got an unexpected keyword argument 'name'

2023-07-31 13:07:30.926 [info] [Error - 13:07:30] Server initialization failed.
2023-07-31 13:07:30.926 [info]   Message: Pending response rejected since connection got disposed
  Code: -32097 
2023-07-31 13:07:30.926 [info] [Error - 13:07:30] The Mypy Type Checker server crashed 5 times in the last 3 minutes. The server will not be restarted. See the output for more information.
2023-07-31 13:07:30.926 [info] [Error - 13:07:30] Mypy Type Checker client: couldn't create connection to server.
2023-07-31 13:07:30.927 [info]   Message: Pending response rejected since connection got disposed
  Code: -32097 
2023-07-31 13:07:30.927 [info] [Error - 13:07:30] Restarting server failed
2023-07-31 13:07:30.927 [info]   Message: Pending response rejected since connection got disposed
  Code: -32097 
@ivan-gj ivan-gj changed the title Crashing with Poetry environment "Server initialization failed" with Poetry environment Jul 31, 2023
@karthiknadig karthiknadig self-assigned this Jul 31, 2023
@karthiknadig
Copy link
Member

TypeError: init() got an unexpected keyword argument 'name'

That error usually means you have pygls installed in your environment that is a bit too old.

@karthiknadig karthiknadig added the info-needed Issue requires more information from poster label Jul 31, 2023
@ivan-gj
Copy link
Author

ivan-gj commented Aug 3, 2023

A quick

pip show pygls

shows a

WARNING: Package(s) not found: pygls

Who is supposed to have a dependency on pygls?

@karthiknadig
Copy link
Member

Please use <python> -m pip with <python> being the absolute path to the python in your virtual environment. See here for explanation: https://snarky.ca/why-you-should-use-python-m-pip/

As for the pygls, this extension ships with pygls version 1.0.2 which has the name keyword argument see here

pygls==1.0.2 \

Reference from pygls 1.0.2 see here: https://github.com/openlawlibrary/pygls/blob/v1.0.2/pygls/server.py#L343-L351

The only way you can get this error is if you have pylgs 0.12.4 or older which did not have name keyword:
https://github.com/openlawlibrary/pygls/blob/v0.12.4/pygls/server.py#L328

You may have to verify if PYTHONPATH environment variable is set and pygls might have been pulled from some other source. It is a generic Language server implementation which is used by several packages. so it can be a transitive dependency of something in your environment.

If all of that comes back with no pygls, then could you try this in your terminal:

> python -c "import pygls;print(pygls.__version__)"
> export PYTHONPATH=/home/user/.vscode/extensions/ms-python.mypy-type-checker-2023.1.12061012/bundled/tool/libs
> python -c "import pygls;print(pygls.__version__)"

@ivan-gj
Copy link
Author

ivan-gj commented Aug 4, 2023

Hey!
After installing and uninstalling a bunch of times, and following your commands, all I can say is that:

  • still no trace of any pygls installation --> CORRECTION I have found pygls after adding the PYTHONPATH
  • now the errors from above are gone, and the Mypy Type Checker logs seem to indicate no issue, but I get no error even for the most obvious asdf: int = "asdf" stuff.

@karthiknadig
Copy link
Member

@ivan-gj You might be running into this issue with dmypy: python/mypy#15677

You can use mypy instead of dmypy if you set the mypy-type-checker.path to ["/home/user/.cache/pypoetry/virtualenvs/tariff-tools-sOhTbMWF-py3.7/bin/python", "-m", "mypy"] to switch to using mypy.

@ivan-gj
Copy link
Author

ivan-gj commented Aug 19, 2023

Hi, sorry for the delay, I will keep the investigation going, although it will take a while until I can come back with more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
info-needed Issue requires more information from poster triage-needed
Projects
None yet
Development

No branches or pull requests

2 participants