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

Starting jedi-language-server fails... #20

Closed
slackline opened this issue May 19, 2022 · 3 comments
Closed

Starting jedi-language-server fails... #20

slackline opened this issue May 19, 2022 · 3 comments

Comments

@slackline
Copy link

Hi,

I'm trying to use jedi-language-serveralong with lsp-jedi.

I have jedi-language-serverinstalled under a virtualenv and activate it within Python (via pyvenv-workon) and then try opening a .pyfile. Unfortunately it exits with the message....

Server jedi:12920/starting exited with status exit(check corresponding stderr buffer for details). Do you want to restart it? (y or n)

And I can't ever get it to start. *jedi::stderr* shows the following...

Process jedi stderr finished
Traceback (most recent call last):
  File "/home/neil/.virtualenvs/default/lib/python3.9/site-packages/pygls/protocol.py", line 152, in deserialize_message
    deserialize_params(data, get_params_type)
  File "/home/neil/.virtualenvs/default/lib/python3.9/site-packages/pygls/protocol.py", line 138, in deserialize_params
    data['params'] = params_type(**params)
  File "pydantic/main.py", line 406, in pydantic.main.BaseModel.__init__
pydantic.error_wrappers.ValidationError: 1 validation error for InitializeParams
processId
  value is not a valid integer (type=type_error.integer)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/neil/.virtualenvs/default/bin/jedi-language-server", line 8, in <module>
    sys.exit(cli())
  File "/home/neil/.virtualenvs/default/lib/python3.9/site-packages/jedi_language_server/cli.py", line 125, in cli
    SERVER.start_io()
  File "/home/neil/.virtualenvs/default/lib/python3.9/site-packages/pygls/server.py", line 204, in start_io
    self.loop.run_until_complete(
  File "/usr/lib/python3.9/asyncio/base_events.py", line 647, in run_until_complete
    return future.result()
  File "/home/neil/.virtualenvs/default/lib/python3.9/site-packages/pygls/server.py", line 75, in aio_readline
    proxy(b''.join(message))
  File "/home/neil/.virtualenvs/default/lib/python3.9/site-packages/pygls/protocol.py", line 456, in data_received
    json.loads(body.decode(self.CHARSET),
  File "/usr/lib/python3.9/json/__init__.py", line 359, in loads
    return cls(**kw).decode(s)
  File "/usr/lib/python3.9/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/lib/python3.9/json/decoder.py", line 353, in raw_decode
    obj, end = self.scan_once(s, idx)
  File "/home/neil/.virtualenvs/default/lib/python3.9/site-packages/pygls/protocol.py", line 154, in deserialize_message
    raise JsonRpcInvalidParams()
pygls.exceptions.JsonRpcInvalidParams: Invalid Params

I've reinstalled pyglsundet the virtualenv and its on 0.11.3 with pydantic pegged at 1.8.2 (since pygls requires < pydantic-1.9.0).

(default) ❱ pip show pygls
Name: pygls
Version: 0.11.3
Summary: a pythonic generic language server (pronounced like "pie glass").
Home-page: https://github.com/openlawlibrary/pygls/tree/master/
Author: Open Law Library
Author-email: info@openlawlib.org
License: Apache 2.0
Location: /home/neil/.virtualenvs/default/lib/python3.9/site-packages
Requires: pydantic, typeguard
Required-by: jedi-language-server
(default) ❱ pip show pydantic
Name: pydantic
Version: 1.8.2
Summary: Data validation and settings management using python 3.6 type hinting
Home-page: https://github.com/samuelcolvin/pydantic
Author: Samuel Colvin
Author-email: s@muelcolvin.com
License: MIT
Location: /home/neil/.virtualenvs/default/lib/python3.9/site-packages
Requires: typing-extensions
Required-by: jedi-language-server, pygls
(default) ❱ pip show jedi-language-server            
Name: jedi-language-server
Version: 0.36.0
Summary: A language server for Jedi!
Home-page: https://github.com/pappasam/jedi-language-server
Author: Sam Roeca
Author-email: samuel.roeca@gmail.com
License: MIT
Location: /home/neil/.virtualenvs/default/lib/python3.9/site-packages
Requires: docstring-to-markdown, jedi, pydantic, pygls
Required-by: 

I have no problem starting jedi-language-serverat the command line under the same virtualenv.

Config...

(use-package lsp-mode
  :ensure t
  :defer t
  :config
  (setq lsp-idle-delay 0.5
	    lsp-enable-symbol-highlighting t)
  :commands (lsp lsp-deferred)
  :init (setq lsp-keymap-prefix "C-c l"
	          lsp-bash-highlight-parsing-errors t)
  :hook ((python-mode . lsp)
	     (bash-mode . lsp)
	     (dockerfile-mode . lsp)
	     (groovy-mode . lsp)
	     (html-mode . lsp)
	     (latex-mode . lsp)
	     ;; (markdown-mode . lsp)
	     (org-mode . lsp)
	     (R-mode . lsp)
	     (ess-r-mode . lsp)
	     (sh-mode . lsp)
         (terraform-mode . lsp)))
(use-package lsp-jedi
  :ensure t
  :config
  (with-eval-after-load "lsp-mode"
    (add-to-list 'lsp-disabled-clients 'pyls)
    (add-to-list 'lsp-enabled-clients 'jedi)))

Any advice on how to solve this would be very gratefully received and if I can supply any more information to help debug please let me know.

Thanks.

@fredcamps
Copy link
Owner

@slackline jedi language server must be installed outside virtualenv

@slackline
Copy link
Author

@fredcamps Ah, ok.

I installed jedi-language-server under user with...

❱ pip install --user jedi-language-server
Collecting jedi-language-server
  Using cached jedi_language_server-0.36.0-py3-none-any.whl (30 kB)
Collecting jedi<0.19.0,>=0.18.0
  Using cached jedi-0.18.1-py2.py3-none-any.whl (1.6 MB)
Collecting pydantic<2.0,>=1.7
  Downloading pydantic-1.9.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (12.4 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 12.4/12.4 MB 1.4 MB/s eta 0:00:00
Collecting pygls<0.12.0,>=0.11.1
  Using cached pygls-0.11.3-py3-none-any.whl (86 kB)
Collecting docstring-to-markdown<1.0.0
  Using cached docstring_to_markdown-0.10-py3-none-any.whl (17 kB)
Collecting parso<0.9.0,>=0.8.0
  Using cached parso-0.8.3-py2.py3-none-any.whl (100 kB)
Requirement already satisfied: typing-extensions>=3.7.4.3 in /usr/lib/python3.9/site-packages (from pydantic<2.0,>=1.7->jedi-language-server) (4.2.0)
Collecting pydantic<2.0,>=1.7
  Using cached pydantic-1.8.2-cp39-cp39-manylinux2014_x86_64.whl (11.3 MB)
Collecting typeguard<3,>=2.10.0
  Using cached typeguard-2.13.3-py3-none-any.whl (17 kB)
Installing collected packages: typeguard, pydantic, parso, docstring-to-markdown, pygls, jedi, jedi-language-server
Successfully installed docstring-to-markdown-0.10 jedi-0.18.1 jedi-language-server-0.36.0 parso-0.8.3 pydantic-1.8.2 pygls-0.11.3 typeguard-2.13.3

..and tried opening a .py file without having any virtualenv activated and get the same error stemming from pygls and pydantic...

Traceback (most recent call last):
  File "/home/neil/.local/lib/python3.9/site-packages/pygls/protocol.py", line 152, in deserialize_message
    deserialize_params(data, get_params_type)
  File "/home/neil/.local/lib/python3.9/site-packages/pygls/protocol.py", line 138, in deserialize_params
    data['params'] = params_type(**params)
  File "pydantic/main.py", line 406, in pydantic.main.BaseModel.__init__
pydantic.error_wrappers.ValidationError: 1 validation error for InitializeParams
processId
  value is not a valid integer (type=type_error.integer)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/neil/.local/bin/jedi-language-server", line 8, in <module>
    sys.exit(cli())
  File "/home/neil/.local/lib/python3.9/site-packages/jedi_language_server/cli.py", line 125, in cli
    SERVER.start_io()
  File "/home/neil/.local/lib/python3.9/site-packages/pygls/server.py", line 204, in start_io
    self.loop.run_until_complete(
  File "/usr/lib/python3.9/asyncio/base_events.py", line 647, in run_until_complete
    return future.result()
  File "/home/neil/.local/lib/python3.9/site-packages/pygls/server.py", line 75, in aio_readline
    proxy(b''.join(message))
  File "/home/neil/.local/lib/python3.9/site-packages/pygls/protocol.py", line 456, in data_received
    json.loads(body.decode(self.CHARSET),
  File "/usr/lib/python3.9/json/__init__.py", line 359, in loads
    return cls(**kw).decode(s)
  File "/usr/lib/python3.9/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/lib/python3.9/json/decoder.py", line 353, in raw_decode
    obj, end = self.scan_once(s, idx)
  File "/home/neil/.local/lib/python3.9/site-packages/pygls/protocol.py", line 154, in deserialize_message
    raise JsonRpcInvalidParams()
pygls.exceptions.JsonRpcInvalidParams: Invalid Params

Which is the same error, albeit the files are under ~/.local/lib/python3.9/site-packages/ rather than ~/.virtualenvs/default/lib/python3.9/site-packages/.

As this is a problem stemming from types in pygls do you think I should report upstream?

@fredcamps
Copy link
Owner

@slackline perhaps it should be opened at pappasam/jedi-language-server

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

2 participants